Let's start with the usual disclaimer: I am not a developer! That being said, I have used Laravel extensively for web projects with it being designed to "ship fast". Laravel is a PHP framework, and I really enjoy its simplicity, as well as how fast it is to get started. Meetup.mu is built on Laravel, for example, and was made and shipped in a weekend.
So, when I got a reply to a comment on the Rust subreddit about Cot, a framework which resembles Django and would scratch my Laravel itch in Rust, I was very excited to give it a look. In order to compare apples to apples, I wanted to translate meetup.mu into Cot and document my experience with it, both as the developer and the sysadmin pushing it to my homelab.
The Cot Project
The source code can be found here, on my personal Forgejo instance: git.alexbissessur.dev/alex/meetup-mu-cot . If you're familiar with Laravel, the src directory will feel like home.
- The static directory has the assets, such as css or images.
- main.rs features the roots and some boilerplate code which you don't really need to mess around with.
- The models directory has the structs which map onto the database with the ORM.
- The controllers directory has the functions which interact with the database, as well as render the html found in templates.
- The migrations directory has auto-generated code, based off the model, for setting up the database.
The directory structure is slightly custom, with `controllers` and `models` being my approach to making Cot a bit closer to Laravel.
Cot's website is on https://cot.rs/ and lists a lot of the perks and features it has. I'd recommend checking it out, as well as the quick start guide, which gets you running your first Cot application in minutes. There's also a disclaimer which says that Cot is work-in-progress and there are some missing features here and there. Though, I had the chance to talk to the two maintainers and they seem very proactive at taking feedback for certain features and fixes, or ways things can be done better. So while it says "do not use in prod", I will gladly pretend I can't read, and use it in prod :)
Performance Testing
The performance is the main reason for me to be writing this blogpost. As I am still developing, everything is running on my more-than-capable desktop, with an 8c/16t Ryzen 7 2700x @3.7GHz, and 16GB DDR4 RAM. Certainly a different monster to my homelab of power-saving mini PCs. To run the Cot project properly, I use cargo run --release to test without any debug or other performance-inhibiting settings. I am testing using oha, a simple CLI load balancing tool, with the following command: oha -z "60s" -c "51" "http://localhost:8000"
I also tried to make the test environments similar for both Cot and Laravel. Both applications had a sqlite database in the project root, with identical data. They were also run "bare-metal", meaning no containers, VMs, or anything of the sort. They also had full access to the resources of my desktop.
Cot Performance
So! The interesting data! In the span of 60 seconds, Cot served around 45,000 requests per second, with the following instance being 48k. From the screenshot, you can also see the response time was mostly 1.744ms with a median of 1.02ms. It also sent 450MB of traffic in a second, otherwise 3.5Gbps.

Serving all these requests brought the process cpu usage up to 50%, with all 16 threads running at 50% and my CPU boosting to 4GHz. This value varied slightly with higher performing benchmarks hitting more req/s but using up to 70% CPU. On the RAM side, the process sat comfortably at 20MB or less.

Laravel Performance
I ran Laravel using FrankenPHP, which promises better performance over other methods of running Laravel such as with nginx or php-fpm. The command I used to run the project is: php artisan octane:frankenphp However, most responses landed in the 0.404 second bracket, with only 265 requests per second. A far cry from Cot's 44,000. Traffic stats mean I won't be stressing my local 1-gigabit LAN, or my 50Mbps home plan, with around 5.3Mbps.

Serving these requests used only 10% of my CPU power, but ate up 800MB of RAM! There wasn't much variation here, despite running the test several times. In my opinion, it's eating waaay too much RAM for the current memory prices :D

Conclusion
The conclusion, for the most part, is obvious. Laravel is built to be shipped fast, but compromises heavily on performance. Plain Rust, particularly with rudimentary actix_web, is not the fastest to get started with, as I learnt while creating KRaft, but, it makes up for that by being incredibly performant and light on resources. Now, I see Cot lowering the complexity, with a developer experience close to that of Laravel, but not compromising on performance.
I'm very enthusiastic to see where Cot brings Rust in the web dev sphere, and am very hopeful for its future!
The modern softeare developer has achieved incredible feats: they have negated orders of magnitude of hardware improvements through nothing but their awful code.
Bonus Data!
I finished translating meetup.mu into Cot. For the most part. I have interesting data from both Cot and Laravel. Though, keep in mind that these numbers do not represent what each framework can do - they are both running on underpowered micro PCs with only 1Gbps between them, which is shared by all the other services, as well as Longhorn. Another disclaimer is that my cluster is built from 3 Dell Optiplex Micros with i3-8300Ts of 4 threads and 32GB DDR4, which is very limiting in terms of CPU. Neither deployment has resource requests or limits. I was just messing around, so didn't repeat the experiment to get averages.
Testing on the Cot implementation averaged at 1250 requests per second, and average response time of 0.04s.

With the original Laravel version, I had 136 requests per second, with average response of 0.37s.
