r/archlinux • • Jun 01 '16

Why did ArchLinux embrace Systemd?

This makes systemd look like a bad program, and I fail to know why ArchLinux choose to use it by default and make everything depend on it. Wasn't Arch's philosophy to let me install whatever I'd like to, and the distro wouldn't get on my way?

527 Upvotes

359 comments sorted by

View all comments

Show parent comment

9

u/jgomo3 Jun 01 '16

r. Handling dependencies is a complex topic and you don't want to deal with it in shell code. Systemd has it built-in (and with socket-activation, a much better mechanism to deal with dependencies).

Hello. I'm a bit ignorant in this and would like to understand what does it mean "socket-activation" and how is it related with "dependency management".

21

u/morhp Jun 01 '16

For example usually you have a web server that listens on port 80 and if it receives data on port 80, it sends back the requested website.

With socket activation, you can have systemd or xinetd listen on port 80 and only when it receives data, then the real web server is started and systemd/xinetd forwards the data to the web server.

This makes sense if you only rarely use the web server for example. With socket activation, it only runs when it's really needed instead of running in the background the whole time.

28

u/2brainz Developer Fellow Jun 01 '16

Rarely needed services is only one use case. There are more. I mentioned one: If everything were socket-activated, systemd would open all the sockets at startup and all daemons would start as they are needed. If a daemon is not up yet, the dependent process would block on the socket until the daemon has taken over. In this ideal situation, you don't need any explicit dependencies.

4

u/bushwacker Jun 01 '16

Web server startups are not brisk, especially if using ORM and many tables. I can't really imagine a web server being deployed that has a low probability of being used.

Was this just an off the cuff example?

Also even if it was somerhing as trivial as SSHD it's not burning cycles while listening. Any configuration issues that stop it from starting are not reported at startup.

Is this something that actually aids system admins?

9

u/morhp Jun 01 '16

This is just a simple example. Obviously you wouldn't do that for a full apache web server for many reasons. On the other hand, if you just have a simple http based system monitor on your raspberry pi it can make a lot of sense to start the server only when it's used.

Socket based activation is also useful for services like vnc servers. Each client can connect to the same port and xinetd or systemd spawns a new xvnc instance for each client.

or it is useful for dependency management, because a service that depends on another service's socket doesn't need to wait for the other service to start up, it can simply start up and connect to the socket created by systemd which will potentially buffer any data until the other service is ready.

1

u/[deleted] Jun 01 '16

[removed] — view removed comment

4

u/morhp Jun 02 '16

It's not a new concept. But systemd manages it better. Instead of one service started by cron and the next by xinetd and the next by sysvinit they are now all managed by the same system with the same configuration file layout with the same dependency mechanism.

-1

u/[deleted] Jun 03 '16

[removed] — view removed comment

2

u/morhp Jun 03 '16

I'm not trying to defend systemd, but it does a lot things a lot better than xinetd, for example logging, handling service crashes, dependencies and so on.

0

u/[deleted] Jun 03 '16

Common cause and special cause (statistics)


Common mode failure, or common cause, failure has a more specific meaning in engineering. It refers to events which are not statistically independent. That is, failures in multiple parts of a system caused by a single fault, particularly random failures due to environmental conditions or aging. An example is when all of the pumps for a fire sprinkler system are located in one room. If the room becomes too hot for the pumps to operate, they will all fail at essentially the same time, from one cause (the heat in the room).[1] Another example is an electronic system wherein a fault in a power supply injects noise onto a supply line, causing failures in multiple subsystems.

This is particularly important in safety-critical systems using multiple redundant channels. If the probability of failure in one subsystem is p, then it would be expected that an N channel system would have a probability of failure of pN. However, in practice, the probability of failure is much higher because they are not statistically independent; for example ionizing radiation or electromagnetic interference (EMI) may affect all the channels.[2]


I am a bot. Please contact /u/GregMartinez with any questions or feedback.

3

u/zoredache Jun 01 '16

Web server startups are not brisk,

Apache/NGINX don't startup quickly, but you really don't need much to respond to http requests. You can build a http server in a simple bash script that only handles a specific task, if you use the socket activation features of systemd or inetd.

3

u/zoredache Jun 01 '16

what does it mean "socket-activation"

Old-school telnetd, and ftpd. When an incoming request was received the appropriate daemon was started. In the distant past we didn't have huge amounts of memory to just leave programs running waiting for incoming connections. We had one really small program running (inetd) that listened for incoming requests and then launched things as needed.

0

u/Leonidas_from_XIV Jun 02 '16

Yes, and killed after the connection closed. But maybe you want to have the program running after it was used to speed up the next request?

Also, as others noted, the dependencies do not have to be specified explicitly, the daemons are started on demand when any service requests them, not when a static init file decides to better start it now because someone in the future might need it or worse, forget to do it and some service in the future will fail because of a missing dependency.

0

u/yrro Jun 02 '16

Yes, and killed after the connection closed. But maybe you want to have the program running after it was used to speed up the next request?

Then you don't override the default behaviour of Accept=false.

2

u/leonardodag Jun 01 '16

Socket activation means that if you have a program which is used by communicating through a socket, you can create it's socket and then start any dependencies right away, at the same time the socket's program is started - thus better using you system's resources during boot. That's because when another process tries to communicate with it, it will send data to the socket, who will queue it until the program actually starts listening on the socket. A possibly better explanation is on Lennart's blog.