A few days ago, I read Craig Morten's post: What Is The Best Deno Web Framework? It gives an overview of all the Deno frameworks and compares all the aspects of them. If you haven't read about it, I highly encourage you to do so.
From Craig's post, the section "Performance" is fascinating; In his environment, Deno HTTP module gets almost the same result(even more) as Node HTTP module, which amazes me, even though it's just a "Hello Deno!" benchmark test.
But, I knew it's not true for most of the cases. Because deno HTTP module is written in Typescript. Type checking brings pleasure for development, but it costs more resources in compiler time thus has a negative effect on performance.
(Thanks for Oghenovo Usiwoma and Jonathan Beaumont point out in the comment)
But I've tested it before and never got the same result as his. So I would like to see what would happen when I run tests in a more powerful machine.
- CPU: i5-9600KF @3.7GHz
- RAM: 16GB DDR4 2133MHz
- OS: Windows 10
- Benchmark tool: autocannon
Let's see the result first:
Wow! Looks like deno beat node overall! (at least for the version 14.2.0).
But wait, this benchmark is based on 100 concurrent connections by
autocannon http://localhost:3000/ -c100, which is too many for a small-to-medium-sized server. So I give it another try: this time, I use
-c10, which keeps sending requests in 10 concurrent connections.
This time, node is absolutely the winner. There is a significant difference between the two, node has more than about 10K requests per second than deno.
But, this brings a new question:
A concurrent connection is a connection happening with another connection at the same time.
A user sends a request for an HTML page, then after 5ms
another user sends a request for a css file, which is not considered as a concurrent connection.
Let's say, you have 100 active users on an app. You track these users for an hour and find out each of them makes 60 clicks an hour. That's 6000 total requests on the server, and each request takes 2 seconds(which is very slow). That's 12000 seconds of active connections in 3600 seconds(an hour), which results 3.33 concurrent connections (12000/3600 = 3.33).
If the server is powerful enough to allow processing each request within 1 second?
- The concurrent number is even fewer, less than 1.7.
How about 1000 active users?
- We get 33.3 concurrent connections
Are 100 concurrent connections overkill?
- Yes, absolutely! Except you want to build a enterprise-level application that serves 3000+ active users(in above scenario).
With that said, the result with 10 concurrent connections is more meaningful in reality, Node wins for the performance round.
Though deno performs better in the
-c100 test, which means deno is doing better than node in a higher traffic network. That's great. From what I've seen, companies would prefer Java or other well known and proven languages to handle a huge amount of traffic over deno, since deno is still young and it's not production-ready yet at this point. However, everyone in deno community is making it happening 🔥.
At last, I also want to mention one point. Performance is not the key of success for a dev community. Look at Python and PHP, they preform much slower than node and deno. What makes them popular? The ecosystem and peoples!
Consider of Google handles over 75,000 queries per second.
Can your server handle this amount of request (>40K) per second?