mercredi 9 mai 2018

Why using nginx as the load balancer for your production is really, really not a good idea.

As a freelance developer, I've stumbled upon this situation in various projects, and I want to publicly explain once and for all why the free version of nginx is not ok to use for production load balancing (LB). Here is why.

Let's first note that "health checks"(HC) are *not* available in the free version of nginx, only in the paid version. Using a LB without HC is really not ok for production, and I will now explain why.

Let's suppose you use nginx as a LB to distribute requests between 2 backends, with default parameters for the LB, typically max_fails=1 fail_timeout=10s.

Now let's suppose one of the backends becomes unresponsive. Typically nothing can connect to it, even your SSH client: trying to connect to it takes forever every time, and you eventually get a timeout somehow. This is not a fantasy, this happened to me yesterday in production. These things happen with servers. And suppose the unresponsive backend stays like this for several hours. What happens?

The LB nginx will consider the unresponsive backend as unavailable and stop sending requests to it. It will send all requests to the healthy backend only. Wait...  not really! Every 10s (fail_timeout) it will test whether the unresponsive backend is "back online" by sending a *real* request (from a real user of your app) to the unresponsive backend and see how it goes. It has to use a real request for this purpose, because HC, which are the exact tool for this job, are not available in the free version of nginx.

The LB nginx will wait 60 seconds (default value of proxy_connect_timeout) before deciding that the unresponsive backend will not be available to answer the real request, and then send this request to the healthy backend and eventually answer the user. From the point of view of your user, the page will load ok (HTTP code 200 OK) but will have taken 60 seconds to load!

They are ways to improve this, and I am working on them in my current project, but frankly it is is clumsy and just a bad solution to a real problem. A good solution would be to use the paying version of Nginx which offers HC, or just to use the right tool for the job which is IMHO HAProxy.

TL;DR If you are ok with having, every 10 seconds, one user wait 60 seconds for your app to load, during the several hours when one of your backend is unresponsive, be my guest and use the free version of nginx as a load balancer in production. Otherwise don't.

samedi 24 mars 2018

Fixed my Xpress M2026 Samsung laser printer which was no longer grabbing paper from the tray.

Just opened it, and cleaned up the two gray little rubber rolls (supposed to tract the paper inside and up) using some alcohol wipes (the same you use to clean eyeglasses). Awesome!

dimanche 11 mars 2018

Fixed my aiport extreme 6th generation annoying noise

by simply applying compressed air spray into its small openings. Did not even have to open it!

The paradox between stress and productivity.

I thought for so long that being hyperactive was linked to being productive. How wrong was I!



Actually it turns out that being hyperactive generates a lot of stress (cortisol) and ultimately leads you to burnout.



However if you listen to relaxing music while working, you eliminate the cortisol (stress) generated by your work in a continuous way, which means that at the end you are very productive in a stable way!



I was astonished when I experimented this theory on myself to see how true this is!