Erlang Stuff

Tooling around with a concurrency oriented programming language 

I have a thing for learning new programming languages. Or not so new. Erlang is about twenty years old, and has been used in anger for doing highly concurrent network oriented stuff for a long time. And it shows. It makes slicing and dicing network traffic easy.

 I recently had the requirement to load test a Socks5 proxy. We needed 5,000 concurrent connections to prove that it didn't fall over under client load. The guys tried to do it using the standard suspects (perl, etc) but you wind up having to either run a lot of processes side by side, or deal with poll/select/kpoll/etc.

Erlang is different. It uses green threads to give you the option of using large numbers of  processes to handle concurrent computation. It also abstracts out the handling of network ports so you can just match a process to a port, and deal with the incoming data on an as it arrives basis.

To the right is the code i wrote to create the load. The keep alive server is basically a spawning echo server with the addition that every sixty seconds it'll send a keep alive packet. The client just goes through and opens up connections through the Socks5 proxy to the keep alive server, and keeps them open for a set time. The numbers in the socks client are a lot lower than what I used in the final run =)

keepalive_server 

socks_client2