Jens Rantil's blog

Posted Ons 21 Augusti 2013

Writing a server in Python

This post is partially related to my previous blog post about Rewind.

One of the questions that might hit you is why would you ever write a server in Python?. I've heard many people being raising their concerns when it comes to Python. The biggest ones are obviously concurrency and the GIL. I've also heard arguments related to lack of strict typing, that Java has better IDE support (partially due to...strict typing) and the sheer amount of libraries that other languages, such as Java, has.

Coming from mostly a Java background when it comes to bigger systems, this is a question I've been asking myself too and Rewind gave me some time to review this. Some of my reasons for choosing Python (mostly, as opposed to Java) were:

Would Python stand the test for a rather performant server software? I think so. In Rewind's case I made the assumption that all events would be persisted as one single event stream. Harddrives are great at append-only storage and I was not that worried about concurrency. The concurrency requirements lay in the fanout message pattern used to notify event listeners of newly persisted events. ZeroMQ would deal with that very well. This meant I could/would sleep well at night, not worrying about the Python GIL.

With great server comes great responsibility

The above said, a server requires strict testing to make sure you can be confident that server works as expected. Since Python is a dynamically types language, this puts an extra pressure on testing. Using test coverage as a metric is almost a must.

Category: misc
Tags: python java
Dude, did you like this blog post? Feel free to drop me some bitcoins at 1Q79HGDF3ZjfCwXLAW6e7gX4DeDu2GtZ7v.