this post was submitted on 24 Nov 2024
46 points (100.0% liked)

Selfhosted

40493 readers
727 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

Hi, I want to host a private Lemmy server under example.com mostly to be used without association (federation) with other Lemmy servers - this is due to the nature of the Lemmy server. It is going to be used only by people from a specific country, so in its initial phase, I am pretty sure these people won't care about any other servers not in this country's language. Anyway, that's besides the point.

The thing is I already have a Hetzner instance where I have set up an NGINX server hosting a couple of PHP websites - Wordpress and Mybb forum using mariaDB database and php 8.1.

The instance is running Ubuntu 24.04.1 LTS - which method of installing Lemmy would make sense? Docker, Ansible, or from scratch, as it is documented here https://join-lemmy.org/docs/administration/install_docker.html ?

I just do not want to disturb my currently installed websites on this server.

Any recommendations?

top 14 comments
sorted by: hot top controversial new old
[–] [email protected] 12 points 1 week ago (1 children)

I did it for a year or so, exactly the same thing, I have a bunch of websites and other services like matrix, mastodon, peertube running on that server.

I found out the hard way that Lemmy is really not optimized for single user instances on a small VPS. In the beginning it was OK but the more they optimized for big instances like Lemmy.world and .ml the word it ran with few resources.

In the end it was so bad that it would Hogg all the servers resources and bring the whole server down every couple of hour so that I had to hard reboot it.

The worst part was that this impacted alł my other services and websites which went down with it every couple of hours. I tried to get a beefier server but that only helped until the next update.

In the end I switched to Piefed and couldn't be happier. It uses a lot less resources as a single user instance so I could downgrade the server again and it's written in python so I can much easier help working on it, no need to compile anything, etc. And it has a cool template engine which let's you easily modify how it looks and feels.

[–] [email protected] 2 points 1 week ago* (last edited 1 week ago) (1 children)

I’ve looked at Piefed and I kind of actually wish it were compiled. I come from the Ruby on Rails world and while I love Ruby (and Hanami too!) I’m just tired of interpreted languages (and Python always feels clunky coming from Ruby).

I wish I had the free time to learn Rust or Go, but I would be ecstatic to find a Crystal-based Lemmy server. Maybe when I’m 80 I’ll have the free time to work on that.

[–] AustralianSimon 2 points 1 week ago (1 children)

I've been playing around with Go, I quite like it.

[–] [email protected] 1 points 1 week ago* (last edited 1 week ago) (1 children)

That seems to be the consensus but what keeps me from picking it up quickly is it always looks very low-level (I’ve been in Ruby land for far too long 😆)

[–] [email protected] 2 points 1 week ago* (last edited 1 week ago)

I would really recommend just trying it out too (when RL time allows), all of the low-level stuff is often well hidden or not required to deal with unless you need it, well most of it is and everything having mostly one solution is a nice refresh compared to the hells of scripted languages.

- A long time python dev.

"Import-time" execution was a huge mistake.

[–] [email protected] 11 points 1 week ago (1 children)

If you want it to not affect other systems, a container is the obvious choice.

[–] afcika 3 points 1 week ago (1 children)

If I did not have any constraints, which method would be the best choice? I want to make upgrades as painless as possible as I plan to follow releases to stay up to date.

[–] [email protected] 1 points 1 week ago

I’d say this comes down to your experience with Docker (or whatever you use to containerize).

Generally speaking updates are as easy as pulling the updated image, but if something goes wrong you should know how to run commands inside the container, access the database, etc. Containerization can be painful if you don’t work with it everyday, but at the same time it brings so many advantages and it’s not hard to learn.

[–] [email protected] 4 points 1 week ago* (last edited 1 week ago)

It just comes down to personal preference.

We run ours using the Docker "method", but I sort of wish we had gone the Ansible route. What we have works, but the documentation isn't up to snuff. To do things in Docker (without ansible) you basically still have to reference the Ansible repo and use their lemmy.hjson and their Docker Compose, but they have lots of environmental variables that you have to change yourself instead of Ansible doing it.

I do enjoy just using my normal workflow, which is using Dockge/Portainer as much as possible, but it's a bit of work trying to figure out what Lemmy wants.

[–] [email protected] 3 points 1 week ago* (last edited 1 week ago)

Docker is generally the easiest to install and update, and won't disturb other existing applications.

[–] [email protected] 3 points 1 week ago

First of all: Get the Instance it's own VPS - Lemmy instances are very very fluid with their resources requirements and you don't want the instance to bog down other services you use. Use another cheap VPS instance for your other services and link them up within Hetzner if needed.

This is even more the case if you host a public instance. I would even consider using separate accounts (even though Hetzner does officially not allow that) for that. Because if one of your users does something Hetzner finds ban worthy they will,under ideal circumstances, at least stop your VPS/quarantine it. (Been there) If you are really unlucky (CSAM material posted or federated in your instance) you will get your whole account banned. Which means all your other services are gone,too. (happened to someone I know)

Don't get me wrong,Hetzner is great, I love them. But be aware of these points. They are very proactive when it comes to these points.

Beside that: Use Docker.

[–] [email protected] 2 points 1 week ago* (last edited 1 week ago) (1 children)

Your use-case and situation seems very close to mine except I specifically do not host communities.

First of all, you can run as many services from single nginx as you want (or can handle), usually you do this by having each service on it's own (sub)domain and routing it all to the same IP, nginx then proxies the requests to the corresponding service running locally on a given port (see nginx reverse proxy).

I would definitely recommend docker images unless you have specific needs, afaik the ansible recipe installs and manages a docker compose project too (unless they also added official bare-bones ansible setup). Might be wrong here, I do docker and manage it myself, updating is usually a file edit and two commands away.

About the VPS being enough - from my monitoring, every foreign subscribed community increases the load, with bigger/more active communities increasing it more.
The main limiting resource for my setup is disk space, sometime ago I've calculated my database size is increasing about 1G per month with about 500 subscribed communities and that's only the postgresql database size without any media. The stats from my s3 provider (you can host images locally too), hint that I am gaining 1-5GBs of media per month.

I don't have any metrics how much the amount of active users drains the server as my instance is intentionally small, but I can imagine that having 10-100-1000 active users at the same time would drastically increase the load of at least postgres as well as increase the bandwith.

And about my setup for comparison, I am renting a dedicated server from Hetzner (AX41-NVMe) running a bunch of other services as well (minecraft server, factorio server, file sharing service, ...) and as of the last 30 days my monitoring reports the "average" load average (same for all 1/5/15m) being around 1 core (out of 12 core processor, 6*2 smt).
Memory is sitting at about 50% month average out of 64G.
Though, most of the services are really under-utilized (minecraft) or don't require much (factorio).

Rule of thumb, if your users subscribe to a lot of outside communities expect at least increased disk space consumption, at worst also increased bandwidth and load.
If any of your hosted communities get popular on the wider fediverse, definitely expect increased bandwith and load - more servers hitting your server with more data (upvotes, comments, edits...) means nginx, lemmy and postgres also need to process more.
At baseline there will be a lot of a spiky but small chatter from other instances and the biggest resource drain will be postgres.

I wouldn't personally go into this with anything less then 4 vCPUs, 32G of RAM and non-shared/virtual storage (disk latency kills postgres performance).

[–] [email protected] 2 points 1 week ago* (last edited 1 week ago)

Disk space is definitely an issue, but I think I've got my single user instance dialed in on a 2 vcpu/4gb/30GB RAM Hetzner VPS; a cron job that runs at the first of every month deletes pictrs files over 30 days old. Currently at 74%.

A lot of bean memes died the day that job first ran.

[–] [email protected] 2 points 1 week ago* (last edited 1 week ago)

I would reccommend docker (or k8s if u already have that set up). And do ur nginx with a sperate file for each service instead if everything in nginx.conf. lemmy docker has its own nginx instance so i would simply reccommend doing ssl with ur existing nginx and forwarding that to the lemmy nginx instance.

EDIT: lmk if u want me to publish my setup on git so u can simply clone and be up and running quickly.