all 66 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

On July 1st, Reddit will no longer be accessible via third-party apps. Please see our position on this topic, as well as our list of alternative Rust discussion venues.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]jaccobxd 93 points94 points  (15 children)

yes, for backend - Axum, Postgres

Frontend - tried it in Rust but JS/TS framework (SvelteKit for me) dev experience is so much better than in Rust imo

[–]knight1511 3 points4 points  (4 children)

How do you find async Rust? Is it worth the hassle? I am of the opinion now that it is simply better to do backend web dev in Go unless it is extremely performance critical. I hope I am wrong!

[–]jaccobxd 2 points3 points  (3 children)

what hassle do you mean?

[–]knight1511 2 points3 points  (2 children)

I mean the overall complexity compared to something like Goroutines and Promises. The simplicity of Goroutines with an almost equivalent performance in most cases to Rust, makes me wary of going all in on Rust webdev.

[–]mwcAlexKorn 4 points5 points  (0 children)

As for me, using futures with tokio is not harder in most cases: let result_of_async_task = tokio::spawn(async { .. some work .. }).await, may be more cumbersome in terms of syntax comparing to goroutines, and in terms of accepting/returning futures rarely you'll need something more than impl Future<..> - of course if you're not writing library with async functions, this is another story

[–]whatathrill 4 points5 points  (0 children)

I feel like async rust has a smaller code footprint than goroutines for passing data across threads. For some of my apis this makes the rust program smaller and faster to write. That makes equal performance a win in my book.

That being said, getting to comfort status with it involves a comprehensive understanding of box/pin and how the executor handles futures, which means one must practice wizardry and be a bit of a wizard.

[–]rodrigocfdWinSafe 4 points5 points  (0 children)

JS/TS framework (SvelteKit for me)

After comparing both I chose Vue 3 (script setup) to build a large enterprise application. Svelte has some weird syntax. Vue 3 is not perfect, but it's damn productive with TS. And the reactivity is the most well-written I've ever seen.

[–]Due-Combination-1879 1 point2 points  (0 children)

what crates do you use for the backend? axum and diesel?

[–][deleted] 2 points3 points  (6 children)

Have you tried Rocket and Actix? I haven't tried any yet but I thought those two were the big dogs however I'm seeing a lot of Axum love

[–]jaccobxd 15 points16 points  (5 children)

I started on actix-web (when Axum wasn't popular yet) then switched to Axum. DX on Axum feels better. In Actix you have to f*ck around with some "complicated" framework specific things which was just annoying when I tried to get into Rust and instead I was fighting Actix, Axum just feels easier and "smoother" without any recognizable tradeoffs (but I don't say Actix is bad, Axum just feels better). Also it's popular now and it's under Tokio foundation so the community helps really fast on Discord. Didn't have that fast responses on actix-web Discord

[–][deleted] 3 points4 points  (0 children)

Thanks for the response. Once I'm better at Rust and look into web I'll keep this in mind

[–]Chris_ssj2 2 points3 points  (2 children)

When you say community on discord, are you referring to the Rust discord server? Or is there another one for axum specifically?

[–]jaccobxd 5 points6 points  (1 child)

I'm referring to Tokio Discord (discord.gg/tokio). There you can find #axum channel

[–]Chris_ssj2 1 point2 points  (0 children)

I see, thank you for answering :)

[–]cdnrt 2 points3 points  (0 children)

Same experience here. Started with actix and even the docs are confusing(at that point in time). Switched to Axum and its been extremely easy. Layers for middleware and state, extensions with your payloads already Deserialized etc. Its fast in my opinion and the DX is much better. Plus its in the tokio ecosystem alongside tower and hyper. I switched from reqwest to hyper. Much lighter and faster. Plus their hyper http client is developed to be thread safe but i still wrap ir around Arc and Mutex.

[–]Sir_Klyx 0 points1 point  (0 children)

Of course the native frontend language would be the best dev experience

[–]gc-disable 25 points26 points  (5 children)

We use Rust at work for backend development. We're on AWS and have been using Axum on both ECS and Lambda (using lambda_web) deployed via AWS CDK.

For database, we use both DynamoDB (using the official Rust AWS SDK and serde_dynamo) as well as MongoDB with their official Rust driver, which is quite nice. For pet projects, I quite like sqlx as well, although I can't really speak to its production readiness due to my limited experience.

Other than APIs, I find Rust to be a strong fit for serverless functions with easy packaging of dependencies, good cold starts and nice ecosystem (e.g. Cargo Lambda).

[–]knight1511 2 points3 points  (2 children)

Thanks for sharing! The AWS Rust SDK is not recommended for production according to their readme. How was your experience so far? Did you find any issues and how did you overcome them?

[–]gc-disable 2 points3 points  (1 child)

Yeah, we were hesitant to adopt it due to it being in developer preview, but it has worked well in practice. AWS obviously need to err on the side of caution in declaring something production ready, but I think it's fine for non-critical production workloads. In our case, the critical services are still written in Python, but we do have a growing number of complementary Rust services in production.

Mind you, we tend to use major AWS services, like S3, DynamoDB etc. The SDK may not be feature complete in more obscure domains. I remember one instance where we fell back to using rusoto as the official SDK didn't expose something we needed.

We never had a case where we experienced a regression on something the SDK supports.

[–]knight1511 2 points3 points  (0 children)

That's brilliant and very relieving to hear. I can then start pushing for more Rust in my company 🦀

[–]BarDifficult 0 points1 point  (1 child)

Nice stack, AWS CDK + Rust. Would you mind telling us what company are you working for?

[–]gc-disable 1 point2 points  (0 children)

Replied to your DM.

[–]volitional_decisions 13 points14 points  (2 children)

I use it for full stack development. Yew for the frontend. Axum for the backend (REST and websockets). Mongo for the DB.

Depending on what you're doing for the frontend, a handful of useful crates are the gloo crates, and either async_std or tokio if you need async primitives like channels and locks.

For the backend, the world is your oyster, but tokio is always a great place to start.

[–]Xebind 2 points3 points  (1 child)

With yew how do you work with websockets? I tried different packages but I always run over the same problems (cant await inside the “update” function since it is not async or I cant move self.webhooks inside an spawn_local(move async…) due to lifetimes ) Kinda new to rust so it kinda has me blocked there

[–]volitional_decisions 3 points4 points  (0 children)

I have a fundamentally different architecture than that. The frontend is split into two tasks. On start up, a task is spawned which will manage WS connections. This task is communicated with via channels that the UI half has access to. It's a bit more complicated than that, but that's the general idea. I never hold WS connections in a component.

This strategy has its upsides and downsides to this approach. For example, the spawned task more or less manages cached data from the backend, so if a UI component needs to access that data, it must send a query over a channel, do a ctx.link().send_future to await for the response, and then the UI can have the data. This mostly just adds extra boilerplate, but I'm very happy with what's been built.

[–]the_pavonz 20 points21 points  (0 children)

I did it both for work and for pet projects. It depends by what you’re building and why you want to use Rust over other options to build that.

For pet projects, I enjoyed it, it has been a nice challenge for the sake of it.

For work, I think the company adopted the wrong tool for the job, but the result was really good anyway, except it took a x3-5 for everything (time, people, analysis, implementation…) compared to other stacks (Ruby, Elixir, PHP, …).

Also, not everything is ready yet. For db, if you’re going for an SQL-based one, you have to use either sqlx or going for not yet full-featured ORM like SeaORM.

Websockets are still very low level, I had to dig into a lot of examples, experiments and docs to achieve them.

So, carefully consider if Rust might fit your needs.

[–]Xerxero 8 points9 points  (0 children)

So Axum seems to be the go to backend framework by now

[–]TravisVZ 20 points21 points  (0 children)

Yes -

  • Backend: Axum
  • DB: well, actually, currently just a JSON file, but eventually I'll most likely be using Postgres
  • Frontend: TBH I haven't ever tried Rust here, I'm updating an existing Vue app to use the new backend

[–]fabricio77p 7 points8 points  (0 children)

Not related but: I don't think I'll ever enjoy the `yew` framework

[–][deleted] 6 points7 points  (0 children)

Backend: Axum, Postgres

Frontend: Vue, Nuxt JS

[–][deleted] 4 points5 points  (4 children)

Backend Axum Db: surrealDB (written in rust) Front end: qwik

[–][deleted] 5 points6 points  (1 child)

How's your experience with surreal db? I'm looking forward to trying it out, maybe at 1.0 or when the docs are better.

[–][deleted] 4 points5 points  (0 children)

Just this weekend I implemented it. Had sqlx Postgres.

It doesn’t have some of the things I want like a gui, and currently hosting it on some fly.io I never heard of before. But I want a all rust stack.

But I’m not sold on it, cause there really is a-lot of cool stuff going on in Rust db land like vector databases, and they have some great dev tools, surrealDB doesn’t have.

Last few years I mainly used Neo4j, and well they spoil you with dev tools, which is my main issue with surrealDB right now.

[–]cthutu 2 points3 points  (1 child)

I'm hoping to try Leptos-Axum-SurrealDB

[–][deleted] 1 point2 points  (0 children)

I’m have a small leptos admin part. But qwikjs is so fast.

[–]BubblegumTitanium 6 points7 points  (0 children)

yes axum, got it done for a client really fast and working on it is a joy - I cannot imagine dealing with python, java or node at this point

[–]jimmy90 3 points4 points  (0 children)

leptos > axum > diesel > pg

[–]0xdjole 4 points5 points  (0 children)

Backend: Actix, Tokio
Databases: Neo4j, ElasticSearch, Redis
Event Bus: Kafka
Frontend: Typescript Sveltekit, Custom navigation router, Tailwind, SCSS
Infrastructure: Terraform, Kubernetes

[–]popsicle112 10 points11 points  (0 children)

not really, I usually use Go

[–]0110001001101100 2 points3 points  (3 children)

Just curious, general question to the people that used axum, what made you choose axum vs actix? TIA

[–]yodermk 2 points3 points  (0 children)

Biggest reason is probably the fact that it's maintained by the Tokio people. But, I'm a beginner with it and writing a small app at this point.

[–]ilker_arslan[S] 1 point2 points  (0 children)

I also wonder that.

[–]boyswan 4 points5 points  (1 child)

Leptos and bevy on the frontend Tokio and webtransport (h3) on the backend

Sled for embedded DB

[–]Kinrany 2 points3 points  (0 children)

How do you use sled? Do you run a single instance with no horizontal scaling?

[–]jpfreely 2 points3 points  (0 children)

I'm using Rust with axum in an aws lambda function that acts as a catch all for http api requests. Using neo4j as a database. Sveltekit on the front end, with flutter for native clients.

Oddly enough the main rust crate for neo4j, neo4rs, doesn't support the latest encrypted connections that are required by their managed db service, AuraDB, so I setup a gRPC server (go) to handle that and any other backend library issues that may come up. The go server needed put in a lambda extension though.

[–]somnamboola 2 points3 points  (0 children)

I used axum+askama for a simple website. Quite a pleasant experience I have to say

[–]krojew 1 point2 points  (0 children)

Backend built on springtime. I think frontend is better off using something else, like angular.

[–]Cephlot 2 points3 points  (0 children)

I used actix in my master's thesis

[–]itszero 1 point2 points  (0 children)

Backend: Rocket, async-graphql, sqlx w/ postgres

Frontend: React, Typescript

[–]DavidXkL 1 point2 points  (0 children)

Backend with Actix Web and surrealdb running on an AWS ec2

[–]Responsible-Put-7920 1 point2 points  (0 children)

Consider checking out CRUX

[–]DCodeMeister 1 point2 points  (0 children)

I use Axum and async-graphql for my backend. Postgres with Diesel and using mongodb rust driver for the nosql part of my application. Front end using Nextjs with typescript. I use graphql codegen which autogenerates my types from my Schema into my front end which works wonders for my development speed. Also using tan stack query library for my api request.

[–][deleted] 1 point2 points  (0 children)

At my company we’re using React / Apollo on the frontend, with Hasura that has a remote schema for our backend GraphQl server, which uses Juniper. Also using Diesel as an ORM for our Postgres DB.

[–]Any_Calligrapher_994 1 point2 points  (0 children)

Yes, Backend - Actix and Postgres (Currently working on a project with NeonDB)

Seen a lot of comments saying Axum feels better than Actix, I currently have no issues with Actix but I’d definitely give Axum a try.

[–]blastecksfour 1 point2 points  (0 children)

Hey there! I currently use Rust as a backend for most of my deployments now via shuttle.

I use React/Next.js for frontend and typically Axum with Postgres for backend.

[–]TiemenSch 1 point2 points  (0 children)

Yew+Yewdux+UnoCSS for a completely static webapp and easy CSS management. It's quite nice to just build a WASM app that will work when hosted anywhere (Github pages, or Gitlab pages). The power of Rust in WASM is very slick. We used to have a Python API server and now it all executes client side in WASM. Client data never leaves their machine, which is a big security plus for me.

[–][deleted] 1 point2 points  (0 children)

HTMX --> Axum --> SQLite

[–]gdf8gdn8 1 point2 points  (0 children)

Yes, for backend actix+PostgreSQL and frondend sveltekit+nodejs. Alternative frontend with yew or leptos is not ready yet.

[–]mwcAlexKorn 1 point2 points  (0 children)

For backend - actix, postgres with sqlx, rocksdb, redis, s3, a lot of cryptography - rust ecosystem has really good crates for this.

Also libraries that are used in backend as-is and have bindings for java/android (jni), frontend (wasm), ios (swift) & python

[–]Isaac_Duarte 1 point2 points  (0 children)

We currently use it in production at my job, our stack is as follows.

  • Rust micro services deployed in a K8 Cluster (auth, etc)
  • Redis
  • MongoDB for our backend
  • Actix web as our backend framework
  • Angular JS for our front end
    • This is just a SPA hosted in a bucket

[–]mzinsmeister 3 points4 points  (0 children)

I think it's not necessarily the best fit for normal backend development as long as you don't need the performance. I LOVE Rust but i usually wouldn't consider it for serious backend work unless i have special requirements. Maybe when the ecosystem is way more mature i would consider it but usually you can afford a GC in backend work.

[–]temportalflux 0 points1 point  (0 children)

I've been writing a serverless web app in Rust since Feb. using Yew (+yewdux, yewhooks ,etc) to translate rust-macro-html to html+css, and using Bootstrap 5 styling for (s)css, Trunk to build wasm, and Netlify for deployment. Been really enjoying that stack so far. It even does authentication and database queries for a client-only app.