Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Real Cross-Platform: Can the ASP.NET Ecosystem Do It for Servers?

Real Cross-Platform: Can the ASP.NET Ecosystem Do It for Servers?

Christian Weyer

October 15, 2015
Tweet

More Decks by Christian Weyer

Other Decks in Programming

Transcript

  1. Christian  Weyer • Co-­founder,  co-­owner and principal consultant at  Thinktecture

    AG • Focus  on – Mobile  &  web-­based  application  architectures – Interoperability,  cross-­device – Pragmatic  end-­to-­end  solutions • Microsoft  MVP  for ASP.NET  (Architecture) ASP.NET  Web  API  /  vNext Advisory  Board  Member ASPInsider,  AzureInsider • Google  GDE  for AngularJS • http://blogs.thinktecture.com/cweyer [email protected] @christianweyer 2
  2. Talking Points • Modern  Business  Applications • Target  Architecture •

    ASP.NET  Web  API  &  SignalR on  Mono • ASP.NET  5 • Cross-­Platform Database 3
  3. Cross-­Platform • Windows  is a  proven server operating system •

    Linux  strong  in  server landscape/hosting – Licenses &  costs – Lower system footprint – Microsoft  Azure offers Linux  out-­of-­the-­box • Virtualization environments are going to rule – VMs – Docker • Developing applications on  Windows,  Linux  or MacOSX 5
  4. Building  Server  Solutions • JVM:  Java,  Scala  etc. • Full

    Stack:  JavaScript  in  Browser,  node.js  in   Backend • .NET – Stable,  mature – especially on  the server – No fragmentation like  on  the client-­side • .NET  vNext &  ASP.NET  vNext enable the next step 6
  5. 8

  6. 9

  7. Target  Architecture Needed • Necessity for a  modern  applications landscape

    is a  service-­based architecture – Services  !=  SOA  J • Often deployed as a  distributed application architecture – Online  vs.  Offline – Light-­weight communication 11
  8. 13 Target  Architecture for SPAs Web/Application  Server Browser  Engine HTML

    CSS JS Assets index.html Client  Logic  (JS) Server  Logic SPA Stock Push Service Products Web  API Orders Web  API HTTPS HTTPS HTTPS WebSockets HTTPS Config Other Services/ Web  APIs View  (HTML,  CSS) View  (HTML,  CSS) View  (HTML,  CSS) JSON JSON JSON
  9. ASP.NET  Web  API • Implementing light-­weight architectures with HTTP-­basedAPIs •

    Separate  technology stack,  no dependency on  ASP.NET – Has similarities to ASP.NET  MVC,  but  completely different  code base • Based  on  OWIN 15
  10. Implementing  a  Web  API • Define  routes • Derive  from

     ApiController • Implement  actions – Actions  map  to  HTTP  methods – Prefix  method  name  with  desired  HTTP  method  – e.g.   PostComment – Or  use  [HttpGet/Post/Put/Delete] • Several  hosting  options,  e.g. – ASP.NET  Web  Application  (IIS) – Self-­host  server  (console  application,  Windows  service,   etc.) 16
  11. Push  Services  Pattern • ‘Push  Services’  are  really  not  an

     official  pattern – Observer  pattern,  anyone? • Model  a  service  that – accepts  incoming  connections  from  callers – is  able  to  push  data  down  to  callers – abstracts  from  communication  nitty-­gritty  details • Realize  Publish-­Subscribe  semantics – Based  on  standard  web  technologies  with  reach  in  mind – With  maximum  reach  into  any  device,  platform Push Service Consumer Send data External event (Database) External event (Message queue) External event (Other actor) Notify [data] 17
  12. ASP.NET  SignalR • SignalR – Server-­side  framework  to  write  push

     services – Set  of  client  libraries  to  make  push  service   communication  easy  to  use  on  any  platform – Optimized  for  asynchronous  processing • Abstracts  from  the  different  techniques  to   implement  pushing  data – Mental  model  is  a  persistent  connection – Volatile,  non-­durable • Negotiation  of  transport: WebSockets,  SSE,  Forever  Frame,  Long  Polling 18
  13. ASP.NET  SignalR Development • Extensible  framework  &  pipeline – Based

     on  interfaces  &  DI • Two  programming  models – Persistent  connections – Hubs • Hubs  offer  a  pre-­defined  application-­level   protocol  in  an  RPC-­ish style – Easy-­to-­get-­going   way  for  80/20  situations 19
  14. ASP.NET  Web  API  &  SignalR – with Mono • Web

     API  2  &  SignalR 2  run on  Mono – Windows,  MacOSX &  Linux – Tested with 3.12;;  issues in  4.0.x;; works in  4.2  Alpha • Self-­Hosted – Web-­Hosted has issues • Limitations in  3.12 – OWIN  &  IPrincipal behavior – CORS 20
  15. .NET  2015 RyuJIT  +  SIMD Garbage  Collector Runtime  components Compilers

    .NET  Compiler  Platform   (Roslyn) Languages  innovation .NET  Framework  4.6   .NET  Core  5   Fully-­featured  and  integrated   .NET  libraries  and  runtime  for  Windows Modular  and  optimized   .NET  libraries  and  runtimes Base  class   libraries NuGet  packages Libraries
  16. ASP.NET  5  (aka  vNext) • Next  version of ASP.NET  has

    version 5 • Runs  on  .NET  4.6,  Mono  or CoreCLR • MVC‘s next release is named ‚6‘ • Web  API  is gone (no longer a  framework on  its own) – Integrated  with MVC – Common  routing,  controllers etc. • SignalR still  a  separate  thing 23
  17. Web  APIs  in  MVC  6 • Entirely integrated into MVC

     Services – One view onto the world of HTTP • Entirely new pipeline implementation – Based on  the ideas of OWIN • Deriving from base controller no longer necessary – Useful helpers can be reached via  base class • Quite straight forward to port over from Web  API  2 25
  18. ASP.NET  5  is  fast • …  and  will  be  even

     faster  in  future 26 https://github.com/aspnet/benchmarks
  19. ASP.NET  5  Release  Schedule Milestone Release  week Beta6 27  Jul

     2015 Beta7 2  Sep  2015 Beta8 15  Oct  2015 RC1 Nov  2015 1.0.0 Q1* 2016 27
  20. Cross-­Plattform  Database • SQL for classic  relational  data,  schema-­based •

    SQL  Server  does not  run on  non-­Windows   OSes • NoSQL for schema-­free data • SQL  Server  has no NoSQL features (not  yet) 29
  21. PostgreSql • Open  Source,  established since 1996 • Runs  on

     Windows,  Linux,  MacOS  X • Strong  in  classic  SQL  tasks • Supports  document-­based NoSQL since version 9.3 – JSON  and JSONB • npgsql driver for .NET – With ADO.NET  API – Support  for Entity  Framework 30
  22. Summary • Cross-­Platform on  the server is often a  

    deployment/licensing decision • ASP.NET  Web  API  &  SignalR work reliably (enough)  on  Mono  &  Linux  today • Mono  may converge with .NET  Core  as its underpinnings • Maybe you do  not  need to move to ASP.NET  5  (yet) – At  least  not  migrate or port existing applications 31
  23. Resources • ASP.NET  Web  API – http://www.asp.net/web-­api • ASP.NET  SignalR

    – http://www.asp.net/signalr • ASP.NET  5 – http://www.asp.net/vnext • .NET  Core – http://dotnet.github.io/core/ – http://dotnet.readthedocs.org/en/latest/ • Mono – http://www.mono-­project.com/ • Npgsql -­ .Net  Data  Provider  for Postgresql – http://npgsql.projects.pgfoundry.org/ 32