Real-time analytics company Mixpanel has posted an explanation on its engineering blog as to why the company switched the code of its API from Erlang to Python.
The Mixpanel team originally built the API server with Erlang and the framework MochiWeb because of the performance demands of running a real-time data service. However, the team lacked an Erlang expert and the code became difficult to manage over time.
The team settled on using Eventlet, a concurrent networking library for Python:
Since the API server handles and responds with some interesting headers, I decided to use eventlet’s raw WSGI library. Eventlet is actually built to emulate techniques pioneered by Erlang. Its “green threads” are pretty similar to Erlang’s “actors.” The main difference is that eventlet can’t influence the Python runtime, but actors are built into Erlang at a language level, so the Erlang VM can do some cool stuff like mapping actors to kernel threads (one per core) and preemption. We get around this problem by launching one API server per core and load balancing with nginx.
If you’re thinking about using Python for concurrency, the post is worth a look.
On a related note, here’s a benchmark comparing Scale Stack, Node.js, Twisted and Eventlet.