Vaadin scalability-slides

Post on 09-May-2015

1,962 views 0 download

description

Маштабируемость приложений. Узнайте как приложения Vaadin масштабируются при большом числе пользователей.Joonas Lehtinen, VaadinVaadin Developer Meetup, Санкт-Петербург, 24 января 2011 года

transcript

Joonas Lehtinen, PhDVaadin Ltd, CEO

Server-side RIA Scalability

perjantaina 21. tammikuuta 2011

Vaadin is a UI framework

for desktop-like web apps

perjantaina 21. tammikuuta 2011

htmljava

perjantaina 21. tammikuuta 2011

Vaadin valueproposition

simplerforget the web cost-effective

no JavaScript debuggingmodular

extensible ♲

powerfulall Java tools& libraries

more securecode stays in server

open sourcefree Apachelicense

perjantaina 21. tammikuuta 2011

BUTperjantaina 21. tammikuuta 2011

Does ItScale?

perjantaina 21. tammikuuta 2011

Server-side RIA?

perjantaina 21. tammikuuta 2011

“Web 1.0”

DOM

Client Server

ViewHTML Page

over HttpResponse

Controller

Model

Parameters overHttpRequest

DB2

3

4

5

1

perjantaina 21. tammikuuta 2011

Client-side RIA

DOM

Client Server

View

Controller

Model

DB2

3

4

5

1

Requested datato view as

XML / JSON

Changes to modelencoded as parameters

perjantaina 21. tammikuuta 2011

Server-side RIA

DOM

Client Server

ViewHTML Pageover HttpResponse

Controller

Model

Parameters overHttpRequest

DB4

5

6

2

Term

inalAdapter

Term

inalAdapter

Automated bythe RIA framework

3

7

1

9

8

Handled by the framework

perjantaina 21. tammikuuta 2011

Scale?

perjantaina 21. tammikuuta 2011

Server-side RIA Scalability questions

Initial application download and Ajax traffic

Server-side CPUusage by the user interface logic

Server-side memory consumption per session

Top 3 Questions

perjantaina 21. tammikuuta 2011

AnswerDepends on your application

perjantaina 21. tammikuuta 2011

Useful AnswerScales enough for most applications

perjantaina 21. tammikuuta 2011

Big enough application toprove the point?

perjantaina 21. tammikuuta 2011

Movie ticket reservationsystem

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 billiontickets 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 handle2140 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

Business Logic

User Interface Logic

MySQL DB

perjantaina 21. tammikuuta 2011

Business Logic

MySQL DB

countriescities

theatersshows

... rese

rvat

ions

paid

tick

ets

perjantaina 21. tammikuuta 2011

Business Logic

Memcached

MySQL DB

cities, ...

reservations

paidtickets

cities, ...

perjantaina 21. tammikuuta 2011

Vaadin

Logic

UI

Cache

MySQL DB

Tomcat

Vaadin

Logic

UI

Cache

Tomcat

Vaadin

Logic

UI

Cache

Tomcat

perjantaina 21. tammikuuta 2011

Tomcat Tomcat Tomcat

MySQL

ELB

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

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

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

RDS-Large• $0.44 / hour

perjantaina 21. tammikuuta 2011

Benchmark

perjantaina 21. tammikuuta 2011

Test Tomcat Tomcat

ELB

Apache JMetertestrecording

perjantaina 21. tammikuuta 2011

Test Tomcat Tomcat

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

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

ELB

perjantaina 21. tammikuuta 2011

Test Tomcat Tomcat

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

Apa

che

JMet

er

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

perjantaina 21. tammikuuta 2011

Scenarios per minute

One Tomcat Server

0

600

1200

1800

2400

3000

Sales / Minute0

30

60

90

120

150

Avg response (ms)

2000 3000 4000 5000 6000

Average ajax response (ms)

Concurrent simulated users usersperjantaina 21. tammikuuta 2011

Scenarios per minute

One Tomcat Server

0

600

1200

1800

2400

3000

Sales / Minute0

30

60

90

120

150

Avg response (ms)

2000 3000 4000 5000 6000

Average ajax response (ms)

Concurrent simulated users users

GOAL all tickets in 20092140

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

Scenarios per minute

Three Tomcat Servers

0

1200

2400

3600

4800

6000

Sales / Minute0

80

160

240

320

400

Avg response (ms)

2000 3000 4000 5000 6000 18000

Average ajax response (ms)

Concurrent simulated users users

3 se

rver

s

3 se

rver

s

1 server 1 server

perjantaina 21. tammikuuta 2011

3 xservers

2.6 xtransactions

perjantaina 21. tammikuuta 2011

What if we overload the server?

perjantaina 21. tammikuuta 2011

Scenarios per minute

Three Tomcat Servers

0

1200

2400

3600

4800

6000

Sales / Minute0

400

800

1200

1600

2000

Avg response (ms)

2000 3000 4000 5000 6000 18000 28000

Average ajax response (ms)

Concurrent simulated users users

3 se

rver

s

3 se

rver

s

1 server

2 se

rver

s

2 se

rver

s

1 server

perjantaina 21. tammikuuta 2011

Too many users

5 x latency

98% of the transactions

per server

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 hostingcosts?

perjantaina 21. tammikuuta 2011

Servers

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

1 x MySQL Server (RDS-Large)$910 / year (reserved instance)

Total $3640 / year

perjantaina 21. tammikuuta 2011

Network

Elastic Load Balancing$8819 / year

1050TB traffic$86000 / year

Total $94819 / year

perjantaina 21. tammikuuta 2011

Total hosting costs

Hosting costs are 0.00043% of the ticket sales revenues sales

$87 per million sales transactions

Total hosting costs: $100.000 / year

perjantaina 21. tammikuuta 2011