DEV Community

Cover image for Scale to 1000 concurrent users on a raspberry pi 4
Thomas Cross
Thomas Cross

Posted on

Scale to 1000 concurrent users on a raspberry pi 4

I have been investigating rust web frameworks and have to say this one is my favorite. Not just because of its performance, but the features, design choice, and ecosystem.

Actix web is a web framework that uses the actor model to perform HTTP requests. It has middlewares, SSL, HTTP/2, and many "extras".

My main reason for looking into this is because I think Rust can facilitate a future of fast, safe, concurrent software. Coming from php, python, Java, ... the barrier to learning was really to learn Rust(a non object oriented language). I've always wanted to write bare metal web services, but would prefer not to use C++ because of the mistakes we can make.

The results impressed me so much that I decided to publish them here and provide the source code for you as a sort of kicking off point.

This test is a lot like my other one except the redis pool is async via deadpool and obviously actix.

All this service does is use a thread pool in the HTTP handler to get a value from redis and print out some hello world type message. This implementation is more than a 10X improvement in concurrency and 2X in latency compared to the aforementioned warp test. In fact, I noticed redis may have been slowing the benchmark down because it needed so much CPU.

tcross@spongebob:~$ siege -c1000 -r 50 -H  'Content-Type: application/json' 'http://192.168.1.2:8080/tcross/1/index.html'
** SIEGE 4.0.4
** Preparing 1000 concurrent users for battle.
The server is now under siege...
Transactions:              50000 hits
Availability:             100.00 %
Elapsed time:              26.41 secs
Data transferred:           6.68 MB
Response time:              0.52 secs
Transaction rate:        1893.22 trans/sec
Throughput:             0.25 MB/sec
Concurrency:              990.76
Successful transactions:       50000
Failed transactions:               0
Longest transaction:            1.66
Shortest transaction:           0.00
Enter fullscreen mode Exit fullscreen mode

I hope you enjoyed reading this, find me on any channel and ask questions! Here is the source!

Top comments (0)