0
Decomposing applications fordeployability and scalability Chris Richardson Author of POJOs in Action Founder of the origin...
Presentation goal    How decomposing   applications improvesdeployability and scalability             and How Cloud Foundr...
About Chris              3
(About Chris)                4
About Chris()                5
About Chris              6
About Chris   http://www.theregister.co.uk/2009/08/19/springsource_cloud_foundry/                                         ...
vmc push About-Chris     Developer Advocate for       CloudFoundry.comSignup at http://cloudfoundry.com   promo code: Java...
Agenda§The (sometimes evil) monolith§Decomposing applications into services§How do services communicate?§Presentation ...
Let’s imagine you are building an e-commerce application                             10
Traditional web application architecture                         WAR                                StoreFrontUI          ...
But there are problems with a monolithic architecture                          12
Users expect a rich, dynamicand interactive experience                                                           h        ...
Obstacle to frequent deployments§Need to redeploy everything to change one component§Interrupts long running background ...
Overloads your IDE and container     Slows down development    15
Obstacle to scaling development    Accounting team                      E-commerce      Engineering                       ...
Obstacle to scaling development                      WAR        UI team              StoreFrontUI    Accounting team      ...
Obstacle to scaling development   Lots of coordination and    communication required        18
Requires long-term commitment to a technology       stack                   19
Agenda§The (sometimes evil) monolith§Decomposing applications into services§How do services communicate?§Presentation ...
21
The scale cubeY axis -functionaldecompositionScale by                                                                 im i...
Y-axis scaling - application level              WAR                     StoreFrontUI                      Accounting      ...
Y-axis scaling - application level                                        accounting web application                      ...
Partitioning strategies§Partition by verb, e.g. shipping service§Partition by noun, e.g. inventory service§Single Respo...
Real world examples          http://techblog.netflix.com/          Between 100-150 services are accessed to build a        ...
There are drawbacks                      27
Complexity   See Steve Yegge’s GooglePlatforms Rant re Amazon.com                               28
Multiple databases            =Transaction management       challenges                         29
When to use it?  In the beginning: •You don’t need it •It will slow you down              Later on:             •You need ...
But there are many benefits§Scales development: develop, deploy and scale  each service independently§Update UI independ...
Two levels of architecture                            System-levelServicesInter-service glue: interfaces and communication...
If services are small...§Regularly rewrite using a better technology stack§Adapt system to changing requirements and  be...
The human body as a system                             34
50 to 70 billion of your cells die each                  day                                      35
Yet you (the system) remain you                                  36
Can we build software systems  with these characteristics?              http://dreamsongs.com/Files/              DesignBe...
Agenda§The (sometimes evil) monolith§Decomposing applications into services§How do services communicate?§Presentation ...
Inter-service communication options§Synchronous HTTP        asynchronous AMQP§Formats: JSON, XML, Protocol Buffers, Thri...
Asynchronous message-based communication                                 wgrus-billing.war                                ...
Benefits§Decouples caller from server§Caller unaware of server’s coordinates (URL)§Message broker buffers message when ...
Drawbacks§Additional complexity of message broker§RPC using messaging is more complex                                   ...
Writing code that calls       services                          43
The need for parallelism                                   Service B                b = serviceB()                        ...
Java Futures are a greatconcurrency abstraction  http://en.wikipedia.org/wiki/Futures_and_promises                        ...
Akka’s composablefutures are even better                          46
Using Akka futuresdef callB() : Future[...] = ...def callC() : Future[...] = ...def callD() : Future[...] = ...           ...
Spring Integration§Provides the building blocks for  a pipes and filters architecture§Enables development of  applicatio...
Handling failure   Service A                   Service B               Errors happen           in distributed systems     ...
About Netflix          > 1B API calls/day 1 API call average 6 service calls     Fault tolerance is essential        http:...
Use timeouts and retries         Never wait forever   Errors can be transient                             retry           ...
Use per-dependency bounded thread pool Service A    Runnable 1               Task 1     Runnable 2              Task 2    ...
Use a circuit breakerHigh error rate   stop calling temporarily   Down     wait for it to come back up  Slow     gives it ...
On failure          Return cached dataAvoidFailing          Return default data               Fail fast                   ...
Agenda§The (sometimes evil) monolith§Decomposing applications into services§How do services communicate?§Presentation ...
Modular applicationChoice of presentation layer        technology                               56
NodeJS is the fashionable technology                                   57
Why NodeJS?§Familiar Javascript§High-performance, scalable event-driven, non-blocking  I/O model§Over 13,000 modules de...
NodeJS example                                    Handle         Handle filevar http = require(http);          HTTP        ...
NodeJS isn’t the only game in town   JVM-based         http://vertx.io/                                        60
A modern web application                                                   Service 1                 RESTful WS       Node...
NodeJS - using RESTful WS and AMQP                       REST                               ServiceRESTRequests           ...
Agenda§The (sometimes evil) monolith§Decomposing applications into services§How do services communicate?§Presentation ...
Traditional tools: monolithic applications                                         64
Developing modular apps is more difficult§Many more moving parts to manage  •Platform services: SQL, NoSQL, RabbitMQ  •Ap...
Easy polyglot application deployment and service provisioning                                                             ...
Creating a platform service instance$ vmc create-service mysql --name mysql1Creating Service: OK$ vmc services......======...
Multi-application manifest - part 1---applications:  inventory/target:         Path to application    name: inventory    u...
Multi-application manifest - part 2 store/target:  name: store                           Path to application  url: cer-sto...
One command to create platform services anddeploy application$ vmc pushWould you like to deploy from the current directory...
Micro Cloud Foundry: new developer sandbox       App Instances                              Services      Open source Plat...
Using Caldecott to tunnel into your services                                               72
Caldecott = TCP over HTTP            native                                                             native           p...
Using Caldecott…$ vmc tunnel1: mysql-135e02: mysql1Which service to tunnel to?: 2Password: ********Stopping Application: O...
…Using CaldecottLaunching mysql --protocol=TCP --host=localhost --port=10000 --    user=uMe6Apgw00AhS --password=pKcD76PcZ...
Running JUnit test with Caldecott Configure your test code to use port + connection info                                   ...
Summary          77
Monolithic applications aresimple to develop and deploy    BUT have significant        drawbacks                          ...
Apply the scale cube                                                                       §Modular, polyglot, and       ...
Cloud Foundry helps...                                                                             .js                    ...
@crichardson crichardson@vmware.com        http://slideshare.net/chris.e.richardson/               Questions?www.cloudfoun...
Upcoming SlideShare
Loading in...5
×

Decomposing applications for scalability and deployability - javazone2012

739

Published on

Today, there are several trends that are forcing application architectures to evolve. Users expect a rich, interactive and dynamic user experience on a wide variety of clients including mobile devices. Applications must be highly scalable, highly available and run on cloud environments. Organizations often want to frequently roll out updates, even multiple times a day. Consequently, it’s no longer adequate to develop simple, monolithic web applications that serve up HTML to desktop browsers.

In this talk we describe the limitations of a monolithic architecture. You will learn how to use the scale cube to decompose your application into a set of narrowly focused, independently deployable back-end services and an HTML 5 client. We will also discuss the role of technologies such as NodeJS and AMQP brokers. You will learn how a modern PaaS such as Cloud Foundry simplifies the development and deployment of this style of application.

See the video here: http://vimeo.com/49392435

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
739
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
31
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Decomposing applications for scalability and deployability - javazone2012"

  1. 1. Decomposing applications fordeployability and scalability Chris Richardson Author of POJOs in Action Founder of the original CloudFoundry.com @crichardson crichardson@vmware.com http://plainoldobjects.com/ 1
  2. 2. Presentation goal How decomposing applications improvesdeployability and scalability and How Cloud Foundry helps 2
  3. 3. About Chris 3
  4. 4. (About Chris) 4
  5. 5. About Chris() 5
  6. 6. About Chris 6
  7. 7. About Chris http://www.theregister.co.uk/2009/08/19/springsource_cloud_foundry/ 7
  8. 8. vmc push About-Chris Developer Advocate for CloudFoundry.comSignup at http://cloudfoundry.com promo code: JavaZone2012 8
  9. 9. Agenda§The (sometimes evil) monolith§Decomposing applications into services§How do services communicate?§Presentation layer design§How Cloud Foundry helps 9
  10. 10. Let’s imagine you are building an e-commerce application 10
  11. 11. Traditional web application architecture WAR StoreFrontUI Accounting Service MySQL Browser Apache InventoryService Database Shipping ServiceSimple to Tomcat develop test deploy scale 11
  12. 12. But there are problems with a monolithic architecture 12
  13. 13. Users expect a rich, dynamicand interactive experience h oug en ood ’tg HTTP Request isn ure ect Java Web Browser it HTML/Javascript Application Ia rch ty le U s Old Real-time web ≅ NodeJS 13
  14. 14. Obstacle to frequent deployments§Need to redeploy everything to change one component§Interrupts long running background (e.g. Quartz) jobs§Increases risk of failure Fear of change§Updates will happen less often§e.g. Makes A/B testing UI really difficult 14
  15. 15. Overloads your IDE and container Slows down development 15
  16. 16. Obstacle to scaling development Accounting team E-commerce Engineering application Shipping team 16
  17. 17. Obstacle to scaling development WAR UI team StoreFrontUI Accounting team Accounting Inventory team InventoryService Shipping team Shipping 17
  18. 18. Obstacle to scaling development Lots of coordination and communication required 18
  19. 19. Requires long-term commitment to a technology stack 19
  20. 20. Agenda§The (sometimes evil) monolith§Decomposing applications into services§How do services communicate?§Presentation layer design§How Cloud Foundry helps 20
  21. 21. 21
  22. 22. The scale cubeY axis -functionaldecompositionScale by im ingsplitting g s on r ila tin itidifferent things lit art p gs y ata th ale - d sp i s ax in b Z X axis - horizontal Sc duplication 22
  23. 23. Y-axis scaling - application level WAR StoreFrontUI Accounting Service InventoryService Shipping Service 23
  24. 24. Y-axis scaling - application level accounting web application Accounting Service Store front web application inventory web application InventoryService StoreFrontUI shipping web application Shipping Service Apply X axis cloning and/or Z axis partitioning to each service 24
  25. 25. Partitioning strategies§Partition by verb, e.g. shipping service§Partition by noun, e.g. inventory service§Single Responsibility Principle§Unix utilities - do one focussed thing well Something of an art 25
  26. 26. Real world examples http://techblog.netflix.com/ Between 100-150 services are accessed to build a page. http://highscalability.com/amazon-architecture http://www.addsimplicity.com/downloads/ eBaySDForum2006-11-29.pdf http://queue.acm.org/detail.cfm?id=1394128 26
  27. 27. There are drawbacks 27
  28. 28. Complexity See Steve Yegge’s GooglePlatforms Rant re Amazon.com 28
  29. 29. Multiple databases =Transaction management challenges 29
  30. 30. When to use it? In the beginning: •You don’t need it •It will slow you down Later on: •You need it •Refactoring is painful 30
  31. 31. But there are many benefits§Scales development: develop, deploy and scale each service independently§Update UI independently§Improves fault isolation§Eliminates long-term commitment to a single technology stack Modular, polyglot, multi- framework applications 31
  32. 32. Two levels of architecture System-levelServicesInter-service glue: interfaces and communication mechanismsSlow changing Service-levelInternal architecture of each serviceEach service could use a different technology stackPick the best tool for the jobRapidly evolving 32
  33. 33. If services are small...§Regularly rewrite using a better technology stack§Adapt system to changing requirements and better technology without a total rewrite§Pick the best developers rather than best <pick a language> developers polyglot culture Fred George “Developer Anarchy” 33
  34. 34. The human body as a system 34
  35. 35. 50 to 70 billion of your cells die each day 35
  36. 36. Yet you (the system) remain you 36
  37. 37. Can we build software systems with these characteristics? http://dreamsongs.com/Files/ DesignBeyondHumanAbilitiesSimp.pdf http://dreamsongs.com/Files/WhitherSoftware.pdf 37
  38. 38. Agenda§The (sometimes evil) monolith§Decomposing applications into services§How do services communicate?§Presentation layer design§How Cloud Foundry helps 38
  39. 39. Inter-service communication options§Synchronous HTTP asynchronous AMQP§Formats: JSON, XML, Protocol Buffers, Thrift, ...§Even via the database Asynchronous is preferred JSON is fashionable but binary format is more efficient 39
  40. 40. Asynchronous message-based communication wgrus-billing.war Accounting Servicewgrus-store.war wgrus-inventory.war RabbitMQ StoreFrontUI (Message InventoryService MySQL Broker) wgrus-shipping.war ShippingService 40
  41. 41. Benefits§Decouples caller from server§Caller unaware of server’s coordinates (URL)§Message broker buffers message when server isdown/slow 41
  42. 42. Drawbacks§Additional complexity of message broker§RPC using messaging is more complex 42
  43. 43. Writing code that calls services 43
  44. 44. The need for parallelism Service B b = serviceB() Call in parallel c = serviceC() Service A Service C d = serviceD(b, c) Service D 44
  45. 45. Java Futures are a greatconcurrency abstraction http://en.wikipedia.org/wiki/Futures_and_promises 45
  46. 46. Akka’s composablefutures are even better 46
  47. 47. Using Akka futuresdef callB() : Future[...] = ...def callC() : Future[...] = ...def callD() : Future[...] = ... Two calls execute in parallelval future = for { (b, c) <- callB() zip callC(); d <- callD(b, c) And then invokes D } yield dval result = Await.result(future, 1 second) http://doc.akka.io/docs/akka/2.0.1/scala/futures.html Get the result of D 47
  48. 48. Spring Integration§Provides the building blocks for a pipes and filters architecture§Enables development of application components that are •loosely coupled •insulated from messaging infrastructure§Messaging defined declaratively 48
  49. 49. Handling failure Service A Service B Errors happen in distributed systems 49
  50. 50. About Netflix > 1B API calls/day 1 API call average 6 service calls Fault tolerance is essential http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html 50
  51. 51. Use timeouts and retries Never wait forever Errors can be transient retry http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html 51
  52. 52. Use per-dependency bounded thread pool Service A Runnable 1 Task 1 Runnable 2 Task 2 Service B Runnable ... Task ... bounded queue bounded thread pool Fails fast if Limits number ofservice is slow or down outstanding requests http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html 52
  53. 53. Use a circuit breakerHigh error rate stop calling temporarily Down wait for it to come back up Slow gives it a chance to recover http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html 53
  54. 54. On failure Return cached dataAvoidFailing Return default data Fail fast http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html 54
  55. 55. Agenda§The (sometimes evil) monolith§Decomposing applications into services§How do services communicate?§Presentation layer design§How Cloud Foundry helps 55
  56. 56. Modular applicationChoice of presentation layer technology 56
  57. 57. NodeJS is the fashionable technology 57
  58. 58. Why NodeJS?§Familiar Javascript§High-performance, scalable event-driven, non-blocking I/O model§Over 13,000 modules developed by the community§Many JavaScript client frameworks have a NodeJS counterpart, e.g. socket.io 58
  59. 59. NodeJS example Handle Handle filevar http = require(http); HTTP readvar fs = require("fs"); requesthttp.createServer(function (req, res) { fs.readFile(somefile.txt, function (err, data) { if (err) throw err; res.writeHead(200, {Content-Type: text/plain}); res.end(data); });}).listen(1337, 127.0.0.1);console.log(Server running at http://127.0.0.1:1337/); 59
  60. 60. NodeJS isn’t the only game in town JVM-based http://vertx.io/ 60
  61. 61. A modern web application Service 1 RESTful WS Node JSBrowser HTML 5 Server Application Application Service 2 Events Socket.io Socket.io client server ... 61
  62. 62. NodeJS - using RESTful WS and AMQP REST ServiceRESTRequests Node JS Events socket.io AMQP AMQP RabbitMQ Service 62
  63. 63. Agenda§The (sometimes evil) monolith§Decomposing applications into services§How do services communicate?§Presentation layer design§How Cloud Foundry helps 63
  64. 64. Traditional tools: monolithic applications 64
  65. 65. Developing modular apps is more difficult§Many more moving parts to manage •Platform services: SQL, NoSQL, RabbitMQ •Application services: your code§Who is going to setup the environments: •the developer sandbox? •... •QA environments? But Cloud Foundry helps... 65
  66. 66. Easy polyglot application deployment and service provisioning OSS community vFabricPostgres Ap p lica Private   o Clouds   n  S Data Services erv ice  In ter vFabric fac e RabbitMQTM Public Clouds Msg Services Micro Other Clouds Services Additional partners services …
  67. 67. Creating a platform service instance$ vmc create-service mysql --name mysql1Creating Service: OK$ vmc services......=========== Provisioned Services ============+-------------+---------+| Name | Service |+-------------+---------+| mysql1 | mysql |+-------------+---------+
  68. 68. Multi-application manifest - part 1---applications: inventory/target: Path to application name: inventory url: cer-inventory.chrisr.cloudfoundry.me framework: name: spring info: mem: 512M description: Java SpringSource Spring Application exec: mem: 512M instances: 1 services: Required platform services si-rabbit: type: :rabbitmq si-mongo: type: :mongodb si-redis: type: :redis 68
  69. 69. Multi-application manifest - part 2 store/target: name: store Path to application url: cer-store.chrisr.cloudfoundry.me framework: name: spring info: mem: 512M description: Java SpringSource Spring Application exec: mem: 512M instances: 1 services: Required platform services si-mongo: type: :mongodb si-rabbit: type: :rabbitmq 69
  70. 70. One command to create platform services anddeploy application$ vmc pushWould you like to deploy from the current directory? [Yn]:Pushing application inventory...Creating Application: OKCreating Service [si-rabbit]: OKBinding Service [si-rabbit]: OKCreating Service [si-mongo]: OKBinding Service [si-mongo]: OKCreating Service [si-redis]: OKBinding Service [si-redis]: OKUploading Application: Checking for available resources: OK vmc push: Processing resources: OK •Reads the manifest file Packing application: OK Uploading (12K): OK •Creates the required platform servicesPush Status: OKStaging Application inventory: OK •Deploys all the applicationsStarting Application inventory: OKPushing application store...Creating Application: OKBinding Service [si-mongo]: OKBinding Service [si-rabbit]: OKUploading Application: Checking for available resources: OK Processing resources: OK Packing application: OK 70
  71. 71. Micro Cloud Foundry: new developer sandbox App Instances Services Open source Platform as a Service project 10.04 A PaaS packaged as a VMware Virtual Machine Use as a developer sandbox • Use the services from Junit integration tests • Deploy your application for functional testing • Remote debugging from STS 71
  72. 72. Using Caldecott to tunnel into your services 72
  73. 73. Caldecott = TCP over HTTP native native protocol HTTP Service Caldecott Caldecott protocol Service client Port gem application NNNYour computer Cloud Foundry 73
  74. 74. Using Caldecott…$ vmc tunnel1: mysql-135e02: mysql1Which service to tunnel to?: 2Password: ********Stopping Application: OKRedeploying tunnel application caldecott.Uploading Application: Checking for available resources: OK Packing application: OK Uploading (1K): OKPush Status: OKBinding Service [mysql1]: OKStaging Application: OKStarting Application: OKGetting tunnel connection info: OKService connection info: username : uMe6Apgw00AhS password : pKcD76PcZR7GZ name : d7cb8afb52f084f3d9bdc269e7d99ab50Starting tunnel to mysql1 on port 10000.1: none2: mysqlWhich client would you like to start?: 2
  75. 75. …Using CaldecottLaunching mysql --protocol=TCP --host=localhost --port=10000 -- user=uMe6Apgw00AhS --password=pKcD76PcZR7GZ d7cb8afb52f084f3d9bdc269e7d99ab50Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 10944342Server version: 5.1.54-rel12.5 Percona Server with XtraDB (GPL), Release 12.5, Revision 188Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type help; or h for help. Type c to clear the current input statement.mysql>
  76. 76. Running JUnit test with Caldecott Configure your test code to use port + connection info 76
  77. 77. Summary 77
  78. 78. Monolithic applications aresimple to develop and deploy BUT have significant drawbacks 78
  79. 79. Apply the scale cube §Modular, polyglot, and scalable applications §Services developed,Y axis -functionaldecomposition ng deployed and scaled independently i on iti rt pa ta da is- ax Z X axis - horizontal duplication 79
  80. 80. Cloud Foundry helps... .js Ap p lica Private   o Clouds   n  S Data Services erv ice  In ter fac e fac e Public ter r  In Clouds Msg Services ide ov  Pr ud Cl o Micro Clouds Other Services
  81. 81. @crichardson crichardson@vmware.com http://slideshare.net/chris.e.richardson/ Questions?www.cloudfoundry.com promo code: JavaZone2012
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×