SlideShare une entreprise Scribd logo
1  sur  55
Télécharger pour lire hors ligne
Server-side RIA
                                       Scalability
                                       Joonas Lehtinen, PhD
                                           Vaadin Ltd, CEO




perjantaina 21. tammikuuta 2011
Vaadin is a
                UI framework
              for desktop-like
                     web apps


perjantaina 21. tammikuuta 2011
java                   html

perjantaina 21. tammikuuta 2011
more secure
                                    code stays in server      powerful
       open source                                            all Java tools
       free Apache                                            & libraries
       license

                                  Vaadin value
                                   proposition
       simpler
       forget the web                                      cost-effective
                                                           no JavaScript
                                  modular                  debugging
                                  extensible   ♲
perjantaina 21. tammikuuta 2011
BUT
perjantaina 21. tammikuuta 2011
Does It
                 Scale?


perjantaina 21. tammikuuta 2011
Server-side
                 RIA?


perjantaina 21. tammikuuta 2011
“Web 1.0”

                      Client              5
                                                               Server
                                     HTML Page
                        DOM       over HttpResponse     View                4


                                                                                 3
                                                                   Model

                                    Parameters over
                                     HttpRequest
                                                      Controller
                                                                        2
                                                                                DB
                                          1




perjantaina 21. tammikuuta 2011
Client-side RIA

                        Client                  4                     Server
                                          Requested data
                           View             to view as
                                           XML / JSON
                                  5

                           DOM                                Model
                                                                          3
                                  1

                                        Changes to model
                       Controller     encoded as parameters
                                                                               DB
                                                2




perjantaina 21. tammikuuta 2011
Server-side RIA

                    Client                                      8
                                                                                                        Server
                                  9                                                            7
                                      TerminalAdapter




                                                                             TerminalAdapter
                                                           HTML Page
                                                        over HttpResponse                            View            6


                                                           Automated by                                                   5
                     DOM                                 the RIA framework                                      Model

     Handled by the framework                            Parameters over
                                                          HttpRequest                              Controller
                                  1                                                                              4
                                                                                               3                         DB
                                                                2




perjantaina 21. tammikuuta 2011
Scale?



perjantaina 21. tammikuuta 2011
Top 3 Questions
                                  Server-side memory
                                  consumption per session

         Server-side
         RIA Scalability          Server-side CPU
                                  usage by the user
         questions                interface logic


                                  Initial application download
                                  and Ajax traffic


perjantaina 21. tammikuuta 2011
Answer
                 Depends on your
                 application


perjantaina 21. tammikuuta 2011
Useful Answer
                 Scales enough for
                 most applications


perjantaina 21. tammikuuta 2011
Big enough
                 application to
                 prove the point?


perjantaina 21. tammikuuta 2011
Movie ticket
                                  reservation
                                  system



perjantaina 21. tammikuuta 2011
Think
                                   BIG
perjantaina 21. tammikuuta 2011
238
                       countries
perjantaina 21. tammikuuta 2011
6 624
                       theaters
perjantaina 21. tammikuuta 2011
69 347
                       rooms
perjantaina 21. tammikuuta 2011
20.7M
                       seats
perjantaina 21. tammikuuta 2011
3 movies
                                  per night

perjantaina 21. tammikuuta 2011
up to
                  1.9 billion
                  tickets per month

perjantaina 21. tammikuuta 2011
up to
                  224 billion
                  € per year
                  [ assuming 10€ / ticket ]


perjantaina 21. tammikuuta 2011
which is 10X total
                  global box office
                  sales of 30 billion
                  USD in 2009
                  estimated by MPAA

perjantaina 21. tammikuuta 2011
assume
                  • 10% fill rate to reach global sales in 2009
                  • 2 tickets per sales transaction

                  we should be able to handle
                  2140 sales transactions per
                  minute
                  on average - 24/7
                  (assuming uniform load)


perjantaina 21. tammikuuta 2011
How it’s made?



perjantaina 21. tammikuuta 2011
Vaadin Framework

                                  User Interface Logic

                                  Business Logic

                                  MySQL DB




perjantaina 21. tammikuuta 2011
Business Logic




                                                            paid tickets
                                             reservations
                           countries
                               cities
                            theaters
                              shows
                                   ...




                                  MySQL DB
perjantaina 21. tammikuuta 2011
Business Logic

                                          reservations
                         cities, ...


                                                         paid
                                  Memcached              tickets


                         cities, ...



                                  MySQL DB
perjantaina 21. tammikuuta 2011
Tomcat                   Tomcat   Tomcat

            Vaadin                   Vaadin   Vaadin

           UI                       UI        UI

           Logic                    Logic     Logic

           Cache                    Cache     Cache



                                  MySQL DB

perjantaina 21. tammikuuta 2011
ELB

          Tomcat                    Tomcat                            Tomcat
          EC2-Large                 EC2-Large                         EC2-Large
          • 7.5GB mem               • 7.5GB mem                       • 7.5GB mem
          • 2 CPU cores             • 2 CPU cores                     • 2 CPU cores
          • $0.34 / hour            • $0.34 / hour                    • $0.34 / hour




                                  MySQL              RDS-Large
                                                     • $0.44 / hour




perjantaina 21. tammikuuta 2011
Benchmark



perjantaina 21. tammikuuta 2011
test
                            Apache JMeter   recording



                                  ELB

perjantaina 21. tammikuuta 2011
Apache JMeter           t
                                                                t




perjantaina 21. tammikuuta 2011
                                                                t

                                        Apache JMeter

                                        Apache JMeter
                                                        t




                                  ELB
                                        Apache JMeter

                                        Apache JMeter

                                        Apache JMeter

                                        Apache JMeter




                                        Apache JMeter
                                                                2000 threads per server
                                                          14 JMeter servers (EC2-Large)
Apache JMeter           t
                                                          t




perjantaina 21. tammikuuta 2011
                                                          t

                                  Apache JMeter

                                  Apache JMeter
                                                  t




                                  Apache JMeter

                                  Apache JMeter

                                  Apache JMeter

                                  Apache JMeter




                                  Apache JMeter
                                                          2000 threads per server
                                                    14 JMeter servers (EC2-Large)
One Tomcat Server
    Scenarios per minute                                    Average ajax response (ms)
  3000                                                      150

  2400                                                      120

  1800                                                       90

  1200                                                       60

     600                                                     30

         0                                                       0
                                  Sales / Minute                            Avg response (ms)

                                     2000          3000   4000       5000      6000

                                  Concurrent simulated users users
perjantaina 21. tammikuuta 2011
One Tomcat Server
    Scenarios per minute                                    Average ajax response (ms)
  3000                                                      150

  2400                                                      120
                     2140                                        GOAL all tickets in 2009
  1800                                                       90

  1200                                                       60

     600                                                     30

         0                                                       0
                                  Sales / Minute                            Avg response (ms)

                                     2000          3000   4000       5000      6000

                                  Concurrent simulated users users
perjantaina 21. tammikuuta 2011
Goal of selling
             all tickets in the
              world reached
                with only one
                       server!

perjantaina 21. tammikuuta 2011
What happens
                                  with multiple
                                  servers?


perjantaina 21. tammikuuta 2011
Three Tomcat Servers
    Scenarios per minute                                           Average ajax response (ms)
  6000                                                             400

  4800                                                             320


                                                       3 servers




                                                                                                      3 servers
  3600                                                             240

  2400                                                             160

  1200                                                             80

         0                                                           0
                                  1 Sales / Minute
                                    server                                        1 server
                                                                                  Avg response (ms)

                                      2000      3000       4000     5000   6000       18000

                                    Concurrent simulated users users
perjantaina 21. tammikuuta 2011
3x
                                      servers

                                         2.6 x
                                  transactions

perjantaina 21. tammikuuta 2011
What if we
                                  overload the
                                  server?


perjantaina 21. tammikuuta 2011
Three Tomcat Servers
    Scenarios per minute                                                         Average ajax response (ms)
  6000                                                                          2000

  4800                                                                          1600




                                                                                                                   3 servers
                                                                                                                               2 servers
  3600                                                                          1200
                                                      3 servers
                                                                  2 servers
  2400                                                                           800

  1200                                                                           400

         0                                                                           0
                                  1 server
                                     Sales / Minute                                              1 Avg response (ms)
                                                                                                   server
                                      2000    3000          4000              5000       6000   18000   28000

                                      Concurrent simulated users users
perjantaina 21. tammikuuta 2011
Too many users
                  98% of the
                transactions
                   per server
                  5 x latency

perjantaina 21. tammikuuta 2011
Optimizations



perjantaina 21. tammikuuta 2011
1. Profile memory



perjantaina 21. tammikuuta 2011
2. Explicit session
                 clear in the end


perjantaina 21. tammikuuta 2011
3. Minimize
                 database use


perjantaina 21. tammikuuta 2011
4. Move static
                 resources to
                 AWS CloudFront


perjantaina 21. tammikuuta 2011
Expected
                 hosting
                 costs?


perjantaina 21. tammikuuta 2011
Servers
                                  1 x MySQL Server (RDS-Large)
                                  $910 / year (reserved instance)


                                  3 x Tomcat Server (EC2-Large)
                                  $2730 / year total (reserved instance)

           Total $3640 / year




perjantaina 21. tammikuuta 2011
Network
                                  1050TB traffic
                                  $86000 / year


                                  Elastic Load Balancing
                                  $8819 / year

            Total $94819 / year




perjantaina 21. tammikuuta 2011
Total hosting costs

                                  Total hosting costs: $100.000 / year


                                  $87 per million sales transactions


                                  Hosting costs are 0.00043% of
                                  the ticket sales revenues sales



perjantaina 21. tammikuuta 2011
Questions
               Comments




                                  joon as@vaadin.com
                                      +358-40-5035001
                                       sky pe://joonaslehtinen


perjantaina 21. tammikuuta 2011

Contenu connexe

Plus de Rustem Gayfutdinov (6)

Почему у нас менеджеры прототипируют GUI?
Почему у нас менеджеры прототипируют GUI?Почему у нас менеджеры прототипируют GUI?
Почему у нас менеджеры прототипируют GUI?
 
Инструмент прототипирования GUI Machine
Инструмент прототипирования GUI MachineИнструмент прототипирования GUI Machine
Инструмент прототипирования GUI Machine
 
GUI Meetup Spring, Елена Снижко
GUI Meetup Spring, Елена СнижкоGUI Meetup Spring, Елена Снижко
GUI Meetup Spring, Елена Снижко
 
GUI Meetup Spring, Ольга Павлова
GUI Meetup Spring, Ольга ПавловаGUI Meetup Spring, Ольга Павлова
GUI Meetup Spring, Ольга Павлова
 
GUI Meetup Spring, Станислав Ким
GUI Meetup Spring, Станислав КимGUI Meetup Spring, Станислав Ким
GUI Meetup Spring, Станислав Ким
 
GUI Meetup Spring, Рустем Гайфутдинов
GUI Meetup Spring, Рустем ГайфутдиновGUI Meetup Spring, Рустем Гайфутдинов
GUI Meetup Spring, Рустем Гайфутдинов
 

Vaadin scalability-slides

  • 1. Server-side RIA Scalability Joonas Lehtinen, PhD Vaadin Ltd, CEO perjantaina 21. tammikuuta 2011
  • 2. Vaadin is a UI framework for desktop-like web apps perjantaina 21. tammikuuta 2011
  • 3. java html perjantaina 21. tammikuuta 2011
  • 4. more secure code stays in server powerful open source all Java tools free Apache & libraries license Vaadin value proposition simpler forget the web cost-effective no JavaScript modular debugging extensible ♲ perjantaina 21. tammikuuta 2011
  • 6. Does It Scale? perjantaina 21. tammikuuta 2011
  • 7. Server-side RIA? perjantaina 21. tammikuuta 2011
  • 8. “Web 1.0” Client 5 Server HTML Page DOM over HttpResponse View 4 3 Model Parameters over HttpRequest Controller 2 DB 1 perjantaina 21. tammikuuta 2011
  • 9. Client-side RIA Client 4 Server Requested data View to view as XML / JSON 5 DOM Model 3 1 Changes to model Controller encoded as parameters DB 2 perjantaina 21. tammikuuta 2011
  • 10. Server-side RIA Client 8 Server 9 7 TerminalAdapter TerminalAdapter HTML Page over HttpResponse View 6 Automated by 5 DOM the RIA framework Model Handled by the framework Parameters over HttpRequest Controller 1 4 3 DB 2 perjantaina 21. tammikuuta 2011
  • 12. Top 3 Questions Server-side memory consumption per session Server-side RIA Scalability Server-side CPU usage by the user questions interface logic Initial application download and Ajax traffic perjantaina 21. tammikuuta 2011
  • 13. Answer Depends on your application perjantaina 21. tammikuuta 2011
  • 14. Useful Answer Scales enough for most applications perjantaina 21. tammikuuta 2011
  • 15. Big enough application to prove the point? perjantaina 21. tammikuuta 2011
  • 16. Movie ticket reservation system perjantaina 21. tammikuuta 2011
  • 17. Think BIG perjantaina 21. tammikuuta 2011
  • 18. 238 countries perjantaina 21. tammikuuta 2011
  • 19. 6 624 theaters perjantaina 21. tammikuuta 2011
  • 20. 69 347 rooms perjantaina 21. tammikuuta 2011
  • 21. 20.7M seats perjantaina 21. tammikuuta 2011
  • 22. 3 movies per night perjantaina 21. tammikuuta 2011
  • 23. up to 1.9 billion tickets per month perjantaina 21. tammikuuta 2011
  • 24. up to 224 billion € per year [ assuming 10€ / ticket ] perjantaina 21. tammikuuta 2011
  • 25. which is 10X total global box office sales of 30 billion USD in 2009 estimated by MPAA perjantaina 21. tammikuuta 2011
  • 26. assume • 10% fill rate to reach global sales in 2009 • 2 tickets per sales transaction we should be able to handle 2140 sales transactions per minute on average - 24/7 (assuming uniform load) perjantaina 21. tammikuuta 2011
  • 27. How it’s made? perjantaina 21. tammikuuta 2011
  • 28. Vaadin Framework User Interface Logic Business Logic MySQL DB perjantaina 21. tammikuuta 2011
  • 29. Business Logic paid tickets reservations countries cities theaters shows ... MySQL DB perjantaina 21. tammikuuta 2011
  • 30. Business Logic reservations cities, ... paid Memcached tickets cities, ... MySQL DB perjantaina 21. tammikuuta 2011
  • 31. Tomcat Tomcat Tomcat Vaadin Vaadin Vaadin UI UI UI Logic Logic Logic Cache Cache Cache MySQL DB perjantaina 21. tammikuuta 2011
  • 32. ELB Tomcat Tomcat Tomcat EC2-Large EC2-Large EC2-Large • 7.5GB mem • 7.5GB mem • 7.5GB mem • 2 CPU cores • 2 CPU cores • 2 CPU cores • $0.34 / hour • $0.34 / hour • $0.34 / hour MySQL RDS-Large • $0.44 / hour perjantaina 21. tammikuuta 2011
  • 34. test Apache JMeter recording ELB perjantaina 21. tammikuuta 2011
  • 35. Apache JMeter t t perjantaina 21. tammikuuta 2011 t Apache JMeter Apache JMeter t ELB Apache JMeter Apache JMeter Apache JMeter Apache JMeter Apache JMeter 2000 threads per server 14 JMeter servers (EC2-Large)
  • 36. Apache JMeter t t perjantaina 21. tammikuuta 2011 t Apache JMeter Apache JMeter t Apache JMeter Apache JMeter Apache JMeter Apache JMeter Apache JMeter 2000 threads per server 14 JMeter servers (EC2-Large)
  • 37. One Tomcat Server Scenarios per minute Average ajax response (ms) 3000 150 2400 120 1800 90 1200 60 600 30 0 0 Sales / Minute Avg response (ms) 2000 3000 4000 5000 6000 Concurrent simulated users users perjantaina 21. tammikuuta 2011
  • 38. One Tomcat Server Scenarios per minute Average ajax response (ms) 3000 150 2400 120 2140 GOAL all tickets in 2009 1800 90 1200 60 600 30 0 0 Sales / Minute Avg response (ms) 2000 3000 4000 5000 6000 Concurrent simulated users users perjantaina 21. tammikuuta 2011
  • 39. Goal of selling all tickets in the world reached with only one server! perjantaina 21. tammikuuta 2011
  • 40. What happens with multiple servers? perjantaina 21. tammikuuta 2011
  • 41. Three Tomcat Servers Scenarios per minute Average ajax response (ms) 6000 400 4800 320 3 servers 3 servers 3600 240 2400 160 1200 80 0 0 1 Sales / Minute server 1 server Avg response (ms) 2000 3000 4000 5000 6000 18000 Concurrent simulated users users perjantaina 21. tammikuuta 2011
  • 42. 3x servers 2.6 x transactions perjantaina 21. tammikuuta 2011
  • 43. What if we overload the server? perjantaina 21. tammikuuta 2011
  • 44. Three Tomcat Servers Scenarios per minute Average ajax response (ms) 6000 2000 4800 1600 3 servers 2 servers 3600 1200 3 servers 2 servers 2400 800 1200 400 0 0 1 server Sales / Minute 1 Avg response (ms) server 2000 3000 4000 5000 6000 18000 28000 Concurrent simulated users users perjantaina 21. tammikuuta 2011
  • 45. Too many users 98% of the transactions per server 5 x latency perjantaina 21. tammikuuta 2011
  • 47. 1. Profile memory perjantaina 21. tammikuuta 2011
  • 48. 2. Explicit session clear in the end perjantaina 21. tammikuuta 2011
  • 49. 3. Minimize database use perjantaina 21. tammikuuta 2011
  • 50. 4. Move static resources to AWS CloudFront perjantaina 21. tammikuuta 2011
  • 51. Expected hosting costs? perjantaina 21. tammikuuta 2011
  • 52. Servers 1 x MySQL Server (RDS-Large) $910 / year (reserved instance) 3 x Tomcat Server (EC2-Large) $2730 / year total (reserved instance) Total $3640 / year perjantaina 21. tammikuuta 2011
  • 53. Network 1050TB traffic $86000 / year Elastic Load Balancing $8819 / year Total $94819 / year perjantaina 21. tammikuuta 2011
  • 54. Total hosting costs Total hosting costs: $100.000 / year $87 per million sales transactions Hosting costs are 0.00043% of the ticket sales revenues sales perjantaina 21. tammikuuta 2011
  • 55. Questions Comments joon as@vaadin.com +358-40-5035001 sky pe://joonaslehtinen perjantaina 21. tammikuuta 2011