25.11.2014 Views

Conference Notes and Best Practices Release 1.3 ... - Read the Docs

Conference Notes and Best Practices Release 1.3 ... - Read the Docs

Conference Notes and Best Practices Release 1.3 ... - Read the Docs

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Conference</strong> <strong>Notes</strong> <strong>and</strong> <strong>Best</strong> <strong>Practices</strong>, <strong>Release</strong> <strong>1.3</strong><br />

Scaling Your Write-Heavy Django App<br />

Presenter: Tobias McNulty<br />

Track: II<br />

Description:<br />

<strong>Notes</strong>:<br />

Content management systems <strong>and</strong> o<strong>the</strong>r read-heavy Django apps are relatively easy to scale. Scaling<br />

write-heavy apps is ano<strong>the</strong>r matter. In this talk I’ll walk through our experience scaling <strong>the</strong> University of<br />

Chicago’s custom school survey application to h<strong>and</strong>le over 75,000 requests per minute <strong>and</strong> upwards of<br />

9,500 PostgreSQL transactions per second.<br />

1. Project Overview<br />

(a) 5Essential survey module for UChicago<br />

(b) Not about making app fast but scalable, i.e. multiple users at once<br />

2. Scaling Phase 1: Chicago Public Schools<br />

(a) Main issue is bottle-neck entering data to DB<br />

(b) Need an easy way to generate load ... JMeter<br />

(c) Record yourself testing a complex process<br />

(d) HTTP Cookie Manager built into JMeter<br />

(e) pgfouine –> log postgres performance<br />

(f) django-cache-machine for specific caching<br />

(g) Choose what you cache via ‘cached =’ property on a model<br />

(h) use read database to avoid load on write DB<br />

(i) Streaming replication hit PG in 9.1 – try django-balancer<br />

3. Scaling Phase 2: The State of Illinois<br />

(a) gevent worker terrible for CPU-bound applications<br />

(b) NewRelic makes I/O looks expensive, but each worker is processing too many reqs at once<br />

(c) Use a sync worker in gevent <strong>and</strong> it will open up <strong>the</strong> CPU bottleneck<br />

(d) Database was <strong>the</strong> bottleneck, still overloaded<br />

(e) Increased size of EC2 instance, still slow<br />

(f) Figuring out max_connections: not web server count ... Machine resources<br />

(g) Use pgbouncer to share a small number of presistent connections<br />

(h) Run pgbouncer on your web servers using supervisord<br />

(i) Don’t need max_conn to be so low, but know what you’re changing when you change that<br />

4. Slides: http://cakt.us/djangocon-scaling<br />

20 Chapter 3. <strong>Conference</strong>s

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!