I’ve been playing with the tech to rewrite the backend here. I’ll start getting to work on doing that probably next week. And I want to move away from web sockets, combine the front end service with the backend service. will take a while but I think it will be fun to do.
That sounds interesting. Personally I think its a better approach to write a frontend using the http api, like lemmyBB. That means its not necessary to maintain an entire fork, sync it with upstream and so on.
That would be a lot quicker to write. It would still have two running processes and have to go through nginx. Feels like that ads a lot of overhead.
I could start out with that and if its not enough go for a full rewrite.
The easiest way to get started would be if you replace the templates and assets, and leave api calls and routing to lemmyBB. That way you could create something usable within a few days. Templates use handlebars syntax.
nginx adds a lot of overhead for you ? Why do you prefer http over websockets/tcp ?
Its not much for a company who can afford to spin up ten containers but we are running everything in a 40 dollar compute unit. If I can reduce the trips for each request by three I would think it would be nearly three times as fast.
I think I’m just running out of compute power.
There are other things I could try.
Having a really good back end rendered site is super efficient though.
Right now a request comes in to nginx. Nginx points it to the UI nodejs service which then makes a request to the main back end service. Which speaks to postgres, returns to nodejs which renders the HTML, returns to nginx and finally sends it back to you.
We could do all that in a single request to a rust backend and skip nginx and nodejs.
I find it surprising that you actually have performance problems. We used to run lemmy.ml on a 2 cpu vps for 10€ a month, without any problems. Recently we upgraded to 4 cpu due to some kind of ddos, but now resource usage is quite low (load average under 1). Maybe you can share some screenshots of htop or similar (via pm if you want).
Its true that lemmy-ui (nodejs) is not very efficient, but in practice it seems barely noticable. And nginx is very fast, written in C.
I am naive in the ways of small website development… 40$ a month is 480$ a year. Wouldn’t it be cheaper/more powerful to run on a desktop at home ? As I understand, you would have to pay for a public IP forwarding, but power would then be plenty no ?
Is it like Wordpress, where the SQL stores path for retrieving content ? I assumed it was some document store like Mongo
Yes, if you don’t need load balancing, nginx is in the way. I still had no idea that with <100 daily users make such a big load. I would have thought a Raspberry Pi could handle that much
I only get like 20 mb up. I have all the hardware but not the bandwidth. We can handle like 10 users on that but we get a lot more traffic than that.
Assuming images are 99% of bandwidth, maybe offload it to a free image host instead of pulling it through your nginx ? No idea if its possible from a dev standpoint
You could do daily backups of the images locally in case host is gone