<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: load-balancing</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/load-balancing.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2024-07-13T22:51:45+00:00</updated><author><name>Simon Willison</name></author><entry><title>Load Balancing</title><link href="https://simonwillison.net/2024/Jul/13/load-balancing/#atom-tag" rel="alternate"/><published>2024-07-13T22:51:45+00:00</published><updated>2024-07-13T22:51:45+00:00</updated><id>https://simonwillison.net/2024/Jul/13/load-balancing/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://samwho.dev/load-balancing/"&gt;Load Balancing&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Sam Rose built this interactive essay explaining how different load balancing strategies work. It's part of &lt;a href="https://samwho.dev/"&gt;a series&lt;/a&gt; that includes &lt;a href="https://samwho.dev/memory-allocation/"&gt;memory allocation&lt;/a&gt;, &lt;a href="https://samwho.dev/bloom-filters/"&gt;bloom filters&lt;/a&gt; and more.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/algorithms"&gt;algorithms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/explorables"&gt;explorables&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sam-rose"&gt;sam-rose&lt;/a&gt;&lt;/p&gt;



</summary><category term="algorithms"/><category term="load-balancing"/><category term="explorables"/><category term="sam-rose"/></entry><entry><title>The power of two random choices, visualized</title><link href="https://simonwillison.net/2024/Feb/6/the-power-of-two-random-choices-visualized/#atom-tag" rel="alternate"/><published>2024-02-06T22:21:47+00:00</published><updated>2024-02-06T22:21:47+00:00</updated><id>https://simonwillison.net/2024/Feb/6/the-power-of-two-random-choices-visualized/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://twitter.com/grantslatton/status/1754912113246798036"&gt;The power of two random choices, visualized&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Grant Slatton shares a visualization illustrating “a favorite load balancing technique at AWS”: pick two nodes at random and then send the task to whichever of those two has the lowest current load score.&lt;/p&gt;

&lt;p&gt;Why just two nodes? “The function grows logarithmically, so it’s a big jump from 1 to 2 and then tapers off *real* quick.”


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/aws"&gt;aws&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/scaling"&gt;scaling&lt;/a&gt;&lt;/p&gt;



</summary><category term="aws"/><category term="load-balancing"/><category term="scaling"/></entry><entry><title>Scaling React Server-Side Rendering</title><link href="https://simonwillison.net/2019/Dec/30/scaling-react-server-side-rendering/#atom-tag" rel="alternate"/><published>2019-12-30T22:26:24+00:00</published><updated>2019-12-30T22:26:24+00:00</updated><id>https://simonwillison.net/2019/Dec/30/scaling-react-server-side-rendering/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://arkwright.github.io/scaling-react-server-side-rendering.html"&gt;Scaling React Server-Side Rendering&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Outstanding, detailed essay from 2017 on challenges and solutions for scaling React server-side rendering at Kijiji, Canada’s largest classified site (owned by eBay). There’s a lot of great stuff in here, including a detailed discussion of different approaches to load balancing, load shedding, component caching, client-side rendering fallbacks and more.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://news.ycombinator.com/item?id=21890370"&gt;Hacker News&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/scaling"&gt;scaling&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/react"&gt;react&lt;/a&gt;&lt;/p&gt;



</summary><category term="load-balancing"/><category term="scaling"/><category term="react"/></entry><entry><title>Round-robin Django setup with nginx</title><link href="https://simonwillison.net/2009/Dec/21/nginx/#atom-tag" rel="alternate"/><published>2009-12-21T15:43:42+00:00</published><updated>2009-12-21T15:43:42+00:00</updated><id>https://simonwillison.net/2009/Dec/21/nginx/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://smallpy.posterous.com/round-robin-django-setup-with-nginx"&gt;Round-robin Django setup with nginx&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
An nginx trick I didn’t know: a low proxy_connect_timeout value (e.g. 2 seconds) combined with the proxy_next_upstream setting means that if one of your backends breaks a user won’t even see an error, they’ll just have a short delay before getting a response from a working server.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/nginx"&gt;nginx&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ops"&gt;ops&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sysadmin"&gt;sysadmin&lt;/a&gt;&lt;/p&gt;



</summary><category term="django"/><category term="load-balancing"/><category term="nginx"/><category term="ops"/><category term="sysadmin"/></entry><entry><title>Simple CouchDB multi-master clustering via Nginx</title><link href="https://simonwillison.net/2009/Nov/19/cluster/#atom-tag" rel="alternate"/><published>2009-11-19T16:37:36+00:00</published><updated>2009-11-19T16:37:36+00:00</updated><id>https://simonwillison.net/2009/Nov/19/cluster/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://ephemera.karmi.cz/post/247255194/simple-couchdb-multi-master-clustering-via-nginx"&gt;Simple CouchDB multi-master clustering via Nginx&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
An impressive combination. CouchDB can be easily set up in a multi-master configuration, where writes to one master are replicated to the other and vice versa. This makes setting up a reliable CouchDB cluster is as simple as putting two such servers behind a single nginx proxy.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/cluster"&gt;cluster&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/couchdb"&gt;couchdb&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/multimaster"&gt;multimaster&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/nginx"&gt;nginx&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/replication"&gt;replication&lt;/a&gt;&lt;/p&gt;



</summary><category term="cluster"/><category term="couchdb"/><category term="load-balancing"/><category term="multimaster"/><category term="nginx"/><category term="replication"/></entry><entry><title>Quoting Matt Palmer</title><link href="https://simonwillison.net/2009/Nov/3/loadbalancers/#atom-tag" rel="alternate"/><published>2009-11-03T10:45:05+00:00</published><updated>2009-11-03T10:45:05+00:00</updated><id>https://simonwillison.net/2009/Nov/3/loadbalancers/#atom-tag</id><summary type="html">
    &lt;blockquote cite="http://www.anchor.com.au/blog/2009/10/load-balancing-at-github-why-ldirectord/"&gt;&lt;p&gt;I loathe [hardware load balancers]. They’re expensive, restrictive, slow, and generally cause you a lot more pain and suffering than they’re worth. At my last job, one of my projects was to convert most of one of our existing clusters from a load-balancing appliance to use keepalived. Why would we do this? Because the $100k worth of appliance wasn’t capable of doing the job that $15k worth of commodity hardware and an installation of keepalived were handling with ease.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p class="cite"&gt;&amp;mdash; &lt;a href="http://www.anchor.com.au/blog/2009/10/load-balancing-at-github-why-ldirectord/"&gt;Matt Palmer&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/keepalived"&gt;keepalived&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/matt-palmer"&gt;matt-palmer&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ops"&gt;ops&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sysadmin"&gt;sysadmin&lt;/a&gt;&lt;/p&gt;



</summary><category term="keepalived"/><category term="load-balancing"/><category term="matt-palmer"/><category term="ops"/><category term="sysadmin"/></entry><entry><title>Load Balancing in Amazon EC2 with HAProxy</title><link href="https://simonwillison.net/2009/Feb/5/haproxy/#atom-tag" rel="alternate"/><published>2009-02-05T23:12:24+00:00</published><updated>2009-02-05T23:12:24+00:00</updated><id>https://simonwillison.net/2009/Feb/5/haproxy/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://agiletesting.blogspot.com/2009/02/load-balancing-in-amazon-ec2-with.html"&gt;Load Balancing in Amazon EC2 with HAProxy&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Solid tutorial introduction to HAProxy.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/ec2"&gt;ec2&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/griggheorghiu"&gt;griggheorghiu&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/haproxy"&gt;haproxy&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;&lt;/p&gt;



</summary><category term="ec2"/><category term="griggheorghiu"/><category term="haproxy"/><category term="load-balancing"/></entry><entry><title>Minimal nginx conf to split get/post requests</title><link href="https://simonwillison.net/2008/Oct/14/django/#atom-tag" rel="alternate"/><published>2008-10-14T16:33:38+00:00</published><updated>2008-10-14T16:33:38+00:00</updated><id>https://simonwillison.net/2008/Oct/14/django/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.djangosnippets.org/snippets/1141/"&gt;Minimal nginx conf to split get/post requests&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Interesting idea for master-slave replication balancing where GET v.s. POST is load-balanced by nginx, presumably to different backend servers that are configured to talk to either a slave or a master. This won’t deal very will with replication lag though—you really want a user’s session to be bound to the master server for the next few GET requests after data is modified to ensure they see the effects of their updates. UPDATE: Amit fixed my complaint with a neat hack based around a cookie with a max age of 10 seconds.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/masterslave"&gt;masterslave&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/mysql"&gt;mysql&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/nginx"&gt;nginx&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/replication"&gt;replication&lt;/a&gt;&lt;/p&gt;



</summary><category term="load-balancing"/><category term="masterslave"/><category term="mysql"/><category term="nginx"/><category term="replication"/></entry><entry><title>mod_rpaf for Apache</title><link href="https://simonwillison.net/2008/Jun/24/modrpaf/#atom-tag" rel="alternate"/><published>2008-06-24T17:02:55+00:00</published><updated>2008-06-24T17:02:55+00:00</updated><id>https://simonwillison.net/2008/Jun/24/modrpaf/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://stderr.net/apache/rpaf/"&gt;mod_rpaf for Apache&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
A more secure alternative to Django’s equivalent middleware: sets the REMOTE_ADDR of incoming requests from whitelisted load balancers to the X-Forwarded-For header, without any risk that if the load balancers are missing attackers could abuse it to spoof their IP addresses.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/apache"&gt;apache&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/http"&gt;http&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/middleware"&gt;middleware&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/modrpaf"&gt;modrpaf&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/rpaf"&gt;rpaf&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/security"&gt;security&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/xforwardedfor"&gt;xforwardedfor&lt;/a&gt;&lt;/p&gt;



</summary><category term="apache"/><category term="django"/><category term="http"/><category term="load-balancing"/><category term="middleware"/><category term="modrpaf"/><category term="rpaf"/><category term="security"/><category term="xforwardedfor"/></entry><entry><title>Scaling your website with the Perlbal web server (PDF)</title><link href="https://simonwillison.net/2008/Jun/17/revolution/#atom-tag" rel="alternate"/><published>2008-06-17T22:39:29+00:00</published><updated>2008-06-17T22:39:29+00:00</updated><id>https://simonwillison.net/2008/Jun/17/revolution/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://w3.linux-magazine.com/issue/84/Perlbal.pdf"&gt;Scaling your website with the Perlbal web server (PDF)&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Perlbal documentation is pretty thin on the ground; this is a really useful introduction from Frank Wiles.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="http://blog.revsys.com/2008/06/django-software.html"&gt;Frank Wiles&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/frank-wiles"&gt;frank-wiles&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/pdf"&gt;pdf&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/perlbal"&gt;perlbal&lt;/a&gt;&lt;/p&gt;



</summary><category term="frank-wiles"/><category term="load-balancing"/><category term="pdf"/><category term="perlbal"/></entry><entry><title>Load Balancer Update</title><link href="https://simonwillison.net/2008/May/1/load/#atom-tag" rel="alternate"/><published>2008-05-01T10:06:13+00:00</published><updated>2008-05-01T10:06:13+00:00</updated><id>https://simonwillison.net/2008/May/1/load/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://barry.wordpress.com/2008/04/28/load-balancer-update/"&gt;Load Balancer Update&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
WordPress.com has switched from Pound to nginx for load balancing, resulting in a significant drop in CPU usage. I’ve been using nginx on my little VPS for over a year now with no complaints, nice to know it scales up as well as down.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/nginx"&gt;nginx&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/pound"&gt;pound&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/wordpress"&gt;wordpress&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/wordpresscom"&gt;wordpresscom&lt;/a&gt;&lt;/p&gt;



</summary><category term="load-balancing"/><category term="nginx"/><category term="pound"/><category term="wordpress"/><category term="wordpresscom"/></entry><entry><title>A Fair Proxy Balancer for Nginx and Mongrel</title><link href="https://simonwillison.net/2007/Dec/9/fair/#atom-tag" rel="alternate"/><published>2007-12-09T14:57:44+00:00</published><updated>2007-12-09T14:57:44+00:00</updated><id>https://simonwillison.net/2007/Dec/9/fair/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://brainspl.at/articles/2007/11/09/a-fair-proxy-balancer-for-nginx-and-mongrel"&gt;A Fair Proxy Balancer for Nginx and Mongrel&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
nginx uses round robin for proxying by default; this extension module ensures requests are queued up and sent through to backend mongrel servers that aren’t currently busy. I don’t see any reason this wouldn’t work with servers other than mongrel.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/fair"&gt;fair&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/mongrel"&gt;mongrel&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/nginx"&gt;nginx&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/proxies"&gt;proxies&lt;/a&gt;&lt;/p&gt;



</summary><category term="fair"/><category term="load-balancing"/><category term="mongrel"/><category term="nginx"/><category term="proxies"/></entry><entry><title>Client Side Load Balancing for Web 2.0 Applications</title><link href="https://simonwillison.net/2007/Oct/5/digital/#atom-tag" rel="alternate"/><published>2007-10-05T23:29:32+00:00</published><updated>2007-10-05T23:29:32+00:00</updated><id>https://simonwillison.net/2007/Oct/5/digital/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.digital-web.com/articles/client_side_load_balancing"&gt;Client Side Load Balancing for Web 2.0 Applications&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
I recall that early versions of Netscape picked a random server from a hard-coded list each time a user clicked the “What’s New” button, back before server-side scaling techniques were well understood.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="http://www.sitepoint.com/blogs/2007/10/05/client-side-load-balancing-web-20-apps-is-voodoo/"&gt;SitePoint&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/digitalweb"&gt;digitalweb&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/leizhu"&gt;leizhu&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/load-balancing"&gt;load-balancing&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/netscape"&gt;netscape&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/scaling"&gt;scaling&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sitepoint"&gt;sitepoint&lt;/a&gt;&lt;/p&gt;



</summary><category term="digitalweb"/><category term="leizhu"/><category term="load-balancing"/><category term="netscape"/><category term="scaling"/><category term="sitepoint"/></entry></feed>