So it’s been a few days, where are we now?
I also thought given the technical inclination of a lot of our users that you all might be somewhat interested in the what, how and why of our decisions here, so I’ve included a bit of the more techy side of things in my update.
Bandwidth
So one of the big issues we had was the heavy bandwidth caused by a massive amount of downloaded content (not in terms of storage space, but multiple people downloading the same content).
In terms of bandwidth, we were seeing the top 10 single images resulting in around 600GB+ of downloads in a 24 hour period.
This has been resolved by setting up a frontline caching server at pictrs.blahaj.zone, which is sitting on a small, unlimited 400Mbps connection, running a tiny Caddy cache that is reverse proxying to the actual lemmy server and locally caching the images in a file store on its 10TB drive. The nginx in front of lemmy is 301 redirecting internet facing static image requests to the new caching server.
This one step alone is saving over $1,500/month.
Alternate hosting
The second step is to get away from RDS and our current fixed instance hosting to a stand-alone and self-healing infrastructure. This has been what I’ve been doing over the last few days, setting up the new servers and configuring the new cluster.
We could be doing this cheaper with a lower cost hosting provider and a less resiliant configuration, but I’m pretty risk averse and I’m comfortable that this will be a safe configuration.
I woudn’t normally recommend this setup to anyone hosting a small or single user instance, as it’s a bit overkill for us at this stage, but in this case, I have decided to spin up a full production grade kubernetes cluster with a stacked etcd inside a dedicated HA control plane.
We have rented two bigger dedicated servers (64GB, 8 CPU, 2TB RAID 1, 1 GBPS bandwidth) to run our 2 databases (main/standby), redis, etc on. Then a the control plane is running on 3 smaller instances (2GB, 2 CPU each).
All up this new infrastructure will cost around $9.20/day ($275/m).
Current infrastructure
The current AWS infrastructure is still running at full spec and (minus the excess bandwidth charges) is still costing around $50/day ($1500/m).
Migration
Apart from setting up kubernetes, nothing has been migrated yet. This will be next.
The first step will be to get the databases off the AWS infrastucture first, which will be the biggest bang for buck as the RDS is costing around $34/day ($1,000/m)
The second step will be the next biggest machine which is our Hajkey instance at Blåhaj zone, currently costing around $8/day ($240/m).
Then the pictrs installation, and lemmy itself.
And finally everything else will come off and we’ll shut the AWS account down.
appreciate the dedication and transparency! I’m a developer myself but im still learning the basics when it finds to clusters and scaling
@[email protected] thanks for the detailed update!
wool blow poor attraction office or hook view brake coal fruit rule pencil wave touch picture copper approval than awake nose force slope wax edge manager idea pain baby ready shelf word political clock society slow root sticky potato number true under other account little deep for stem test key
make snake place crush umbrella poor free start memory be trade fly porter shoe gold cart hanging spoon dependent that whistle sister scissors school wash powder engine jump young thin wheel rat start cup any parcel rat debt fiction watch have rest poison need in smile tree than unit support
yesterday do tray seem moon window solid mountain sharp green slope weather rail join prison come fight belief look bone amusement to solid army man deep heart sex act expert white slow noise family substance bread waiting pipe distribution tall store future position experience attraction sharp finger plane off elastic
house question every verse experience high view bell loss sticky account kiss stem connection glove plant leg rain ornament tree grain here money snow together other probable net run past care silver nose board mine soap coal face broken knowledge start toe key step knee steam animal learning night sex
now mixed destruction reading journey plough smoke tomorrow spade addition quite bed feather green seed dust common attack fertile rub care journey true design soft motion no key take behaviour tongue red roof road effect across purpose pencil money wash if poor space taste pin sail stick brain where secretary
operation profit open company disease against note brass soap leg machine bucket tight enough organization dead respect connection full nose substance knot cheese straight pipe adjustment short push morning fish any soft copper no parcel butter size word stop slip colour through orange arm moon breath payment destruction ant match
island money rod comb heart knife form summer hand hate work conscious blood debt amount jump purpose only jewel turn chance hope sweet far before be till bird match prose fold ice late he second error will minute smoke system ready jump push than kettle grip before bent high come
father gold throat paint same lip order so turn growth take high growth sudden voice rain exchange fight butter hole probable expert mind thread button rest scissors hate growth drawer sugar name basket regret seem feather now cow under carriage expansion nut pipe current sad pen respect smash bread farm
I’m glad you moved away from AWS, I wouldn’t even consider going for VM hosting and would’ve gone dedicated from the get go (or even self-hosting on a colo / using a good fiber connection at home, but I guess I live in a super privileged country when it comes to ISPs).
Isn’t k8s a bit overkill tho? Front-loaded caching seems to make sense, but a single 10gbit dedi could probably resolve the issue easier and simpler, couldn’t it?
Just to add some more background on this: I used to work tightly with the Network Team in the website team of the biggest contender in its market (can’t disclose which one without people figuring out the company since the market is a bit niche).
We had 20’000 Users a day with a lot of images served.
The whole infrastructure consisted of 2 Firewall servers and the main DB (pSQL) on 2 self-hosted servers (think colo, it was sitting in a very remote location with 2 big diesel generators that would’ve ran the whole datacenter for a week iirc), with 14 Hetzner backend mirrors who ran the whole PHP code, served images and the angular + some weird custom Javascript. Scaling was done by simply throwing more Hetzners at it.
Given that Lemmy runs super performance efficient in comparison to 20 year deprecated PHP code that held together with ducttape, I feel like much less could make it work.
I’m out of my depth but based on the cost savings, seems like a good situation? Kubernetes does scare me though. On the other hand it might be sensible to do this kind of overcorrection just in case the traffic takes another big spike. On the other other hand what you’re describing seems pretty dang effective.
yeah, you pretty much described the use case for k8s. It allows for rapid horizontal scaling, since you can easily throw another machine into the cluster if you need it. It mostly makes sense if you actually have multiple machines sitting idle to begin with, so this technology is mostly used in combination with managed quick rent servers (think AWS).
Beyond that, k8s is kinda fancy for cluster management, but if you don’t have a cluster you kinda don’t need it to begin with. Using simple kernel VMs (think Proxmox) or just Docker works better there. You could still go for k8s since it’s pretty much docker with cluster functionalities, just in case you want to expand eventually (sidenote, docker allows for cluster functionalities too, but they put a price on it, while k8s is open source iirc).
In that company I worked, k8s was considered but ultimately not implemented since it was considered a bit overkill. We already had everything set up with a bunch of bash scripts anyway, so it didn’t matter too greatly to begin with.
I think it’s smart to start with k8s. Better than having to switch over to it later. Since lemmy is growing and will continue to grow.
Learning k8s is the more difficult part. If you know k8s well, it’s much easier to deploy than an ec2 deployment. Especially if you need an ASG and ELBs
I have no idea what a lot of this means but I’m glad to know that our admins are so cool and knowledgeable about it ❤️
a) holy 💩 i had no idea this was so expensive b) please include the ko-fi link for us to help support in future updates.
(link found in other comments)
It’s not supposed to be, that’s the issue. :)
well yeah, but even once the costs are reduced 10x or whatever there will still be costs and it’s still be good to support its continued existence.
Absolutely wild to me that moving off AWS + setting up the caching server will bring overall costs down by around a factor of ten. So glad y’all are capable of the advanced technical junk, and super thankful that you’re willing and able to host the various blahaj.zone instances!
I have no idea what any of this means but I’m glad you were able to figure out and make it cheaper (Hopefully it’s not the emojis causing it because I love my blobcat in a box emoji :))