sergeant-savage / chatter

A small Rust websocket chat
MIT License
4 stars 4 forks source link

Architecture: Consider moving away from a monolith #16

Closed sergeant-savage closed 3 months ago

sergeant-savage commented 5 months ago

At present, our stack involves a Rust websocket server that pulls double duty as an HTTP server. We should consider separating the front end so that the backend server is more free to handle more concurrent messages.

sergeant-savage commented 5 months ago

@Glacier150 @ItsCbass How feasable do y'all think this is? I have no experience in architecture so I'd rather get a second opinion.

Glacier150 commented 5 months ago

I am unfamiliar with the requirements needed for this, so I can't offer any useful insight.

sergeant-savage commented 5 months ago

@Glacier150 At present, the backend is monolithic. The Rust binary that acts as the Websocket server also serves as the HTTP server. It serves the website and handles chat messages at the same time. The issue with this is that when we scale, many people will be loading the site, putting strain on the server. Simultaneously, people will be chatting,putting more stress on the server. We can't ask our server to do 2 things and for them to do them well. We will have to try to separate our frontend web server from our backend Websocket server.

ItsCbass commented 5 months ago

I'm not too experienced with architecture dev but I maybe had a few ideas. From our current setup, the single Rust binary looks like its going to be our performance bottleneck. We could move the frontend HTTP shit to a dedicated static site host, using a CDN for our delivery. As for our backend, we could transition to a cloud-based system like AWS. Maybe even working on some microservices to break things down?? Just some thoughts

sergeant-savage commented 5 months ago

I do think that using a static site host, or even (when we start adding DMs and the like) using a front end server, like a Vercel instance for this purpose. The frontend HTML can just connect to the backend with no issues. Ideally. I have no idea how this would pan out.

sergeant-savage commented 5 months ago

We should look into rewriting the frontend and hosting it on Vercel. We could do a lot nicer things there and have a much nicer frontend that is completely orthogonal from our backend. Plus it'll let us scale without worrying about bottlenecking anything. I have no idea how to develop for the frontend however.

sergeant-savage commented 5 months ago

Ok I just had an idea that was revealed to me in a dream. What if we make a SPA that is hosted on Vercel, rewrite the front-end and backend to work with POST requests instead of a websocket connection, and find someway to stream data back to clients. By making it so that messages are not sent by a websocket connection, we can avoid needlessly keeping open a websocket connection. It will also mean that we can more easily implement things like DMs, I think.

Idk, maybe a pipe dream, but i hope that when all is said and done, this essentially turns out to be an anonymous AIM clone that allows for DMs, a big room for all active users, and creatable group chats. Idk that may be a pipe dream, but pipe dreams stay dreams until you face them head on. Better fail trying to make this a pipe reality than leaving it a pipe dream.

sergeant-savage commented 3 months ago

This issue is stale, and is now a duplicate of #44. Closing.