While Radiocasts is primary an Android application to list and play Russian talk radios podcasts it has a backend crawling the sites to get the feeds of radio programs and provide the to the mobile application. With such backend we have managed to improve the requesting podcasts time from “unacceptable” to “neglected”.

The very first (and current version of the backend) was developed as nodejs+koa2+sqlite web application and this weekend we reproduced it with the aspnet core 2.0 platform just to get clear understanding would it worth to recommend our clients one of the solutions.

Docker image sizes

In the moment of the making radiocast backend we used ubuntu base image to deploy our nodejs applications so it is now. For dotnet applications there at least 2 choices for base images: ASP.NET Core Runtime which in fact is nothing but Debian or to build the application for ubuntu-x64 and build the docker starting from Ubuntu base image which will be ~100Mb less than the Microsoft provided is. Nevertheless we decided to stay with the microsoft image and got this:

As you see dotnet docker is even greater than nodejs is. Sad. I don’t know why i expected the different result, but i really disappointed with it. Although it does not matter in the real life.

Memory

Let’s proceed with the memory requirements – nodejs is known memory hog. May be the compiled c# binaries could play better. Alas:

Once again dotnet app eats at least the same amount of the RAM as nodejs does. This is here i am really surprised and these numbers are meamingfull if we want to provide the client with the cost effective solution capable to work on the smallest cloud server instances.

HTTP Requests

Finally the most interesting part – the requests handling. It is time to say that both applications have identical code: to handle the HTTP request through routing middlewares, try to get the response for the given combination of the query params in the memory cache and build the reply from the SQLite database if the cache misses. Because we query sqlite just exactly one time it may be discarded and the numbers show the framework only performance.

Let’s try to bomb both services with the Apache Benchmark keeping in mind they run on the smallest Digital Ocean ($5/month) instance with 1GB memory and 1CPU. The numbers may be very different with the others configurations.

Summary

For those who are too busy to read the ab outputs: nodejs and dotnet handle http in very same speed under low and moderate load.

dotnet, 1 client: 7

dotnet, 2 clients: 14req/sec

dotnet, 10 clients: 69req/sec

nodejs, 1 clients: 7req/sec

nodejs, 2 clients: 14req/sec

nodejs, 10 clients: 70req/sec

Conclusion

We are not going to declare the nodejs to be a winner just because of seeming to have less footprint because there are at least 2 other reasons we have to take in the consideration: support and calculation heavy requests. Nodejs is good if not perfect to serve the HTTP requests if it can make out the response very fast or get it from some other process like database. Due to single threading nature of the node it is expected to die if need to do some calculations on the request. And here is our case. The above is all about serving the almost idle requests. But the real backend of the Radiocast also does crawling and parsing and that will be another story we would like to tell next week. Personally i will lost some beer if nodejs would not loose the game.


Leave a Reply

Your email address will not be published. Required fields are marked *