Re: Socket activation in parallel?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The default mode (Accept=no) expects your daemon to remain running forever and handle *all* requests in the same instance. Basically once the daemon is started and receives the listening socket, it continues working like a traditional daemon would: start an event loop, perhaps use threads or workers, and so on. Parallelization is up to you.

If you actually want to have one instance per client, then use Accept=yes and make sure your .service unit is templated – i.e. named "foobar@.service". (In this case systemd will call accept() for you, so you'll directly receive the client socket, not the listener socket.)

On Fri, Mar 6, 2020, 00:16 Daniel Tihelka <dtihelka@xxxxxxxxx> wrote:
Hello,
I am adding socket activation to a daemon. It basically works well, but for multiple simultaneous connections, the systemd seems to serialize the incoming requests, spawning the daemon for each request only after the previous request is served (i.e. the daemon terminates).

Is it really the case? Or I am doing something wrong?

I use "classic" approach as:

n = sd_listen_fds(0);
if (n >= 1) {
  for (int fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd++)
 ...


So, the question is: how to convince systemd to spawn instances in parallel every time a new connection is established on the socket, instead of serializing them? Although the server is contacted rather rarely (and thus I deal with socket activation), it takes a longer time to finish with the client. And when would multiple clients contact the server simultaneously, they will wait for a long time ...

Thank you for your advice.

Best regards,
Dan T.



_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel
_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux