High Availability                            Server apps                             Tarek Ziade & Benoît ChesneauMonday, ...
• The C10K problem                    • “Its time for web servers to handle ten                          thousand clients ...
More & more hitsMonday, October 3, 2011                      3
More & more mediaMonday, October 3, 2011                       4
• 1993 - 1998 - CGI (and java applets...)                    • Apache & Prefork - simple                    • Multiprocess...
Monday, October 3, 2011   6
• 1993 - 1998 - CGI (and java applets...)                    • Apache & Prefork - simple                    • Multiprocess...
Clients          Socket          Port 80        Worker    Application                          MinitelMonday, October 3, 2...
Waiting...Monday, October 3, 2011                9
MoarMonday, October 3, 2011          10
ForkMonday, October 3, 2011          11
ForkMonday, October 3, 2011          12
ForkMonday, October 3, 2011          13
ForkMonday, October 3, 2011          14
MultiprocessingMonday, October 3, 2011                     15
multiprocessingMonday, October 3, 2011                     16
• Threads or Events ?                   • Apache, Nginx, Node.js, .... (Erlang)Monday, October 3, 2011                    ...
• MPM Prefork                          $ ab -n 1000000 -c 250 http://127.0.0.1/                          $ ps ax|grep apac...
• 1 master process, several workers                    • Prefork                    • Accepts several connections per work...
• 1 single thread                    • 1 event loop (READ/WRITE)                    • Context switching                   ...
• Nginx VS Apache                    • http://blog.webfaction.com/a-little-holiday-                          presentMonday...
Nginx versus Apache (with the worker-MPM)                for serving a small static file:Monday, October 3, 2011           ...
Memory usageMonday, October 3, 2011                  23
http://www.ostinelli.net/a-comparison-between-misultin-mochiweb-cowboy-nodejs-and-tornadoweb/                             ...
• WSGI (PEP 3333)                    • Prefork - shared socket                    • async & sync workers (gevent, eventlet...
ForkMonday, October 3, 2011          26
Fork + asyncMonday, October 3, 2011                  27
• HTTP Stream                    • Restartless upgrades ala Nginx                    • Simple CLI:                        ...
Monday, October 3, 2011   29
Monday, October 3, 2011   30
asynchronous                               or                          synchronousMonday, October 3, 2011                 ...
• bandwidth-bound & CPU-bound apps                    • Fast operations required                    • Needs a way to hold ...
• websocket, longpolling                    • apps with long, blocking calls                    • streaming               ...
gevent & eventlet                    • Network libraries                    • synchronous API                    • monkey ...
twisted                    • asynchronous library                    • Events & callbacks                    • Twisted ser...
Monday, October 3, 2011   36
• message passing                          • greenlets                          • py.py --withmod-_stackless          http...
• ulimit is your friend                    • somaxcon                    • ...                                            ...
Monday, October 3, 2011   39
Monday, October 3, 2011   40
Firefox SyncMonday, October 3, 2011                  41
Monday, October 3, 2011   42
• 10 frontends web                    • +123 mysql (percona)                    • 6 Open Ldap servers (2 masters, 4 slaves...
• silverlining (http://cloudsilverlining.org/) by                          @ianb                    • kraftwerk (http://kr...
• libcloud (http://libcloud.apache.org/): deploy                          on the “clouds”                    • juju (https...
• Apache Bench (ab)                    • httperf                    • Apache Jmeter                    • Grinder          ...
FunkloadMonday, October 3, 2011              47
FunkloadMonday, October 3, 2011              48
Thanks !                    • @benoitc                    • @tarek_ziade                                          Moar ???...
Upcoming SlideShare
Loading in …5
×

High Availability Server Apps

4,905 views

Published on

Talk we gave Benoit and I at the OSDC/OWF in Paris.

Published in: Technology
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,905
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
69
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide

High Availability Server Apps

  1. 1. High Availability Server apps Tarek Ziade & Benoît ChesneauMonday, October 3, 2011 1
  2. 2. • The C10K problem • “Its time for web servers to handle ten thousand clients simultaneously, dont you think? After all, the web is a big place now. “ • http://www.kegel.com/c10k.htmlMonday, October 3, 2011 2
  3. 3. More & more hitsMonday, October 3, 2011 3
  4. 4. More & more mediaMonday, October 3, 2011 4
  5. 5. • 1993 - 1998 - CGI (and java applets...) • Apache & Prefork - simple • Multiprocessing - threads vs events A bit of historyMonday, October 3, 2011 5
  6. 6. Monday, October 3, 2011 6
  7. 7. • 1993 - 1998 - CGI (and java applets...) • Apache & Prefork - simple • Multiprocessing - threads vs events A bit of historyMonday, October 3, 2011 7
  8. 8. Clients Socket Port 80 Worker Application MinitelMonday, October 3, 2011 8
  9. 9. Waiting...Monday, October 3, 2011 9
  10. 10. MoarMonday, October 3, 2011 10
  11. 11. ForkMonday, October 3, 2011 11
  12. 12. ForkMonday, October 3, 2011 12
  13. 13. ForkMonday, October 3, 2011 13
  14. 14. ForkMonday, October 3, 2011 14
  15. 15. MultiprocessingMonday, October 3, 2011 15
  16. 16. multiprocessingMonday, October 3, 2011 16
  17. 17. • Threads or Events ? • Apache, Nginx, Node.js, .... (Erlang)Monday, October 3, 2011 17
  18. 18. • MPM Prefork $ ab -n 1000000 -c 250 http://127.0.0.1/ $ ps ax|grep apache2|wc -l 152 • MPM Worker (hybride prefork + threads par requêtes) $ ps ax|grep apache2|wc -l 5Monday, October 3, 2011 18
  19. 19. • 1 master process, several workers • Prefork • Accepts several connections per worker • EventsMonday, October 3, 2011 19
  20. 20. • 1 single thread • 1 event loop (READ/WRITE) • Context switching Event LoopMonday, October 3, 2011 20
  21. 21. • Nginx VS Apache • http://blog.webfaction.com/a-little-holiday- presentMonday, October 3, 2011 21
  22. 22. Nginx versus Apache (with the worker-MPM) for serving a small static file:Monday, October 3, 2011 22
  23. 23. Memory usageMonday, October 3, 2011 23
  24. 24. http://www.ostinelli.net/a-comparison-between-misultin-mochiweb-cowboy-nodejs-and-tornadoweb/ ChoiceMonday, October 3, 2011 24
  25. 25. • WSGI (PEP 3333) • Prefork - shared socket • async & sync workers (gevent, eventlet, tornado, ...) • Easy to use in Django, Paster, ...Monday, October 3, 2011 25
  26. 26. ForkMonday, October 3, 2011 26
  27. 27. Fork + asyncMonday, October 3, 2011 27
  28. 28. • HTTP Stream • Restartless upgrades ala Nginx • Simple CLI: $ gunicorn -w 3 test:app • greins (https://github.com/meebo/greins)Monday, October 3, 2011 28
  29. 29. Monday, October 3, 2011 29
  30. 30. Monday, October 3, 2011 30
  31. 31. asynchronous or synchronousMonday, October 3, 2011 31
  32. 32. • bandwidth-bound & CPU-bound apps • Fast operations required • Needs a way to hold incoming connections (cf nginx + gunicorn sync) synchronousMonday, October 3, 2011 32
  33. 33. • websocket, longpolling • apps with long, blocking calls • streaming • slow clients • slowloris & other DoS asynchronousMonday, October 3, 2011 33
  34. 34. gevent & eventlet • Network libraries • synchronous API • monkey patch • co-routines • Code is always running async gevent & eventletMonday, October 3, 2011 34
  35. 35. twisted • asynchronous library • Events & callbacks • Twisted server == single event loop twistedMonday, October 3, 2011 35
  36. 36. Monday, October 3, 2011 36
  37. 37. • message passing • greenlets • py.py --withmod-_stackless http://www.grant-olson.net/python/intro-to-stackless-python stacklessMonday, October 3, 2011 37
  38. 38. • ulimit is your friend • somaxcon • ... TuningMonday, October 3, 2011 38
  39. 39. Monday, October 3, 2011 39
  40. 40. Monday, October 3, 2011 40
  41. 41. Firefox SyncMonday, October 3, 2011 41
  42. 42. Monday, October 3, 2011 42
  43. 43. • 10 frontends web • +123 mysql (percona) • 6 Open Ldap servers (2 masters, 4 slaves) • ~1.5 M active users • ~4 M registered users • ~800 RPS for the storage • CPU: 20% !!! ETooMuchMonday, October 3, 2011 43
  44. 44. • silverlining (http://cloudsilverlining.org/) by @ianb • kraftwerk (http://kraftwerk-wsgi.org) DeployMonday, October 3, 2011 44
  45. 45. • libcloud (http://libcloud.apache.org/): deploy on the “clouds” • juju (https://juju.ubuntu.com/) : ubuntu cloud (openstack + ensemble or ec2) DeployMonday, October 3, 2011 45
  46. 46. • Apache Bench (ab) • httperf • Apache Jmeter • Grinder • Funkload BenchMonday, October 3, 2011 46
  47. 47. FunkloadMonday, October 3, 2011 47
  48. 48. FunkloadMonday, October 3, 2011 48
  49. 49. Thanks ! • @benoitc • @tarek_ziade Moar ???Monday, October 3, 2011 49

×