Rocket vs Actix Web vs others

Hi all

I am new in Rust world and would like to develop rest services. I need a framework but do not know, which web framework should I take. Looking at the Github repo Rocket and Actix Web have the most stars.

Which framework do you recommend me to use?

Thanks

2 Likes

As far as I know rocket should be rather good. It currently requires the nightly compiler, but I heard on the podcast "Rustacean Station" that it should be compatible with stable starting with the next release.

1 Like

I am no hard core web developer, I am new to Rust, I wanted to put up a web server for a simple, low load site, mostly static pages and a simple REST API. Data coming from our CockroachDB database.

As such my comments about Rust web servers is not worth much.

However I'm using Rocket. Selected because I was not aware of any other options but mostly after being fired up by Sergio Benitez presenation on YouTube: "Rocket: Securing the Web at Compile-time": Stanford Seminar - Rocket: Securing the Web at Compile-time - YouTube. It was also confidence inspiring to hear that people like NPM, System76 and Mozilla are using Rocket in production.

It worked out very well. Simple to use for this Rust newbie. Running reliably for months now.

4 Likes

You won't get disappointed with either rocket or actix-web. I am currently using actix-web but have done some work on rocket, too. I think rocket has the better onboarding, thus may be more helpful for Rust beginners. I am using actix-web because of specific features i need and the increased performance demands i have. But i was absolutely happy with rocket in my previous projects.

1 Like

Looking at these TechEmpower benchmarks it appears that Actix is far more performant than Rocket. Is what we see in these benchmarks real?

In short, not really no. TechEmpower has significant and major issues with most frameworks. Some entirely cheating, some using their normal workflows, etc... etc...

Rocket is built on hyper, and in many of my own tests hyper is either on par with or faster than actix-web. Rocket is currently using an older hyper pre-async and all, but that will also be updated next version. I'd vote for Rocket.

3 Likes

Last time I did anything with Rocket, is was purely a synchronous server library. It had a nicer API than actix-web at the time, but IRL slower due to a lack of async abilities. What Rocket was perfect for is what I was using it for: a personal utility app that isn't tied to any single OS. Typically a single consumer at a time (i.e. me) so async didn't matter, and the nicer API was a joy to use.

However. I've used modern day actix-web and the API around routing seems on par with Rocket's nowadays.
Actix is also async, and unless Rocket has undergone some significant development it's still stuck as a synchronous server library. Therefore, to me modern-day actix-web seems like the superior choice, whether it is for a web app or a massively consumed website.

This is the next version everyone keeps talking about. It's not just async'ifying Rocket.rs, it's smoothing out a lot of it, updating things, hopefully going Stable Rust, etc... It looks to be almost ready so hopefully not long, but even now starting with it's current API is perfectly fine, it's not a lot of work to convert (or use git master to play with the current).

That's indeed another thing that at least for now pushes me definitely towards actix: I can use it on stable. The more time goes on, the more my patience is wearing thin for Rocket demanding to use nightly features.

If a certain class of lib simply can't be written safely on stable, then ok I understand. But if competing libraries do allow using stable, then as a consumer of such libraries, the one stuck on nightly is at a definitive competitive disadvantage.

1 Like

Rocket is fully stable rust except for it's procmacro usage, however there is a workaround that is not as clean internally but will keep the public api clean that it looks like they are going to incorporate, which is the last thing to make it fully stable rust.

1 Like

Do you happen to have any links to eg GitHub issues that I can read?
Rocket being available on stable would I think be a good moment to re-evaluate the 2 libraries.

1 Like

Yep, this is the overall "Stable Rust" tracking issue, with links to other areas. By following the links about the various issues (only the proc macro issue is left) you can see what's going on:

They are pushing to finish up async for note, so if dev on the stable rust issue looks a little slow right now that's why, no doubt a PR would be welcome though. ^.^

EDIT: Actually it looks like Rust itself is stabilizing that last thing they need, so they might not need the hack from what I'm reading, nice.

2 Likes

Can confirm — with a PR merged on Rust's side, Rocket will be able to compile on stable. Given that there's still work to be done, there's not interest in putting in proc macro hack just to remove it later.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.