Prev / Next

2009-10-13 / Rails で 1,000 万/日のリクエストをさばく

High Scalability に ravelry というサイトの事例があったのでメモ.

- How Ravelry Scales to 10 Million Requests Using Rails
  http://highscalability.com/blog/2009/9/22/how-ravelry-scales-to-10-million-requests-using-rails.html


統計情報
- 10 million requests a day hit Rails (AJAX + RSS + API)
- 3.6 million pageviews per day
- 430,000 registered users. 70,000 active each day. 900 new sign ups per day.
- 2.3 million knitting/crochet projects, 50,000 new forum posts each day,
  19 million forum posts, 13 million private messages, 8 million photos
  (the majority are hosted by Flickr).
- Started on a small VPS and demand exploded from the start.
- Monetization: advertisers + merchandise store + pattern sales

環境
- Ruby on Rails (1.8.6, Ruby GC patches)
- Percona build of MySQL
- Gentoo Linux
- Servers: Silicon Mechanics (owned, not leased)
- Hosting: Colocation with Hosted Solutions
- Bandwidth: Cogent (very cheap)
- Capistrano for deployment.
- Nginx is much faster and less memory hungry than Apache.
- Xen for virtualization
- HAproxy for load balancing.
- Munin for monitoring.
- Tokyo Cabinet/Tyrant for large object caching
- Nagios for alerts
- HopToad for exception notifications.
- NewRelic for tuning
- Syslog-ng for log aggregation
- S3 for storage
- Cloudfront as a CDN
- Sphinx for the search engine
- Memcached for small object caching

OS が Gentoo だったり,MySQL が Percona な点がちょっと変わってる.

構成

- 7 Servers (Gentoo Linux). Virtualization (Xen) creates 13 virtual servers.
- Front end uses Nginx and HAproxy.
  The request flow: nginx -> haproxy -> (load balanced) -> apache + mod_passenger.
  Nginx is first so it can provide functions like serving static files and
  redirects before passing a request to HAproxy for load balancing.
  Apache is probably used because it is more configurable than Nginx.
- One small backup server.
- One small utility server for non-critical processes and staging.
- 2 32 GB of RAM servers for the master database, slave database, Sphinx search engine.
- 3 application servers running 6 Apache Passenger and Ruby instances, each capped at a pool size of 20. 6 quad core processors and 40 GB of RAM total. There's RAM to spare.
- 5 terabytes of storage on Amazon S3. Cloudfront is used as a CDN.
- Tokyo Cabinet/Tyrant is used instead of memcached in some places for caching larger objects. Specifically markdown text that has been converted to HTML.
- HAproxy and Capistrano are used for rolling deploys of new versions of the site without affecting performance/traffic.

comments powered by Disqus