How to get BACKLOG of listening socket
11,411
ss -lt
gives this value in the Send-Q column.
Related videos on Youtube
Comments
-
Tereska almost 2 years
I have a listening socket on port 80 on ubuntu linux.
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12248/nginx
Is there any way to get backlog value of that socket (backlog value that was sent to listen() call)?
I know that I could view the nginx configuration but configuration file could be changed without reloading nginx with new configuration, so the backlog argument in configuration and in actual LISTEN call could be different.
-
Chucky about 9 yearsThere is nothing useful to do with that information, as there was No point on having more than 640K of RAM.
-
user207421 over 7 years@Chucky The fact is that in the 35-ish years since the BSD Sockets API was designed nobody has seen fit to add such a function, which indicates that no use fort has been found. If you have a counterexample please provide it. Merely juxtaposing two unrelated issues doesn't actually consisting a logical argument, but this particular juxtaposition is poorly chosen for your purpose. The 640k mistake was recognized and addressed within a few years. The lack of a listen backlog API has never been addressed at all, which shows that generations of TCP/IP implementors agree with me.
-
aredridel over 6 yearsError messaging to the operator is one reason. Showing that the backlog is being hit is another, for exposing load status.
-
Schneems about 6 yearsThis shows what the max value is, is there a way to see how many requests are currently queued in the backlog on the socket?
-
user207421 about 6 yearsIf any of these downvoters would care to tell us what they think the name of this non-existent API is, it would be most entertaining.
-
user207421 about 6 years@aredridel The question is about 'the backlg value that was set in the
lsten()
call', not about its current occupancy, and it's hard to see what they operator can do with, or about, that information. -
Ciro Costa over 5 yearsSchneems, you should be able to see that in the other column (Recv-Q). For instance, create a server that listens on a socket but never accepts. If you
telnet
four times and leave that running in the background, you should seeRecv-Q
with a value of 4. -
Ciro Costa over 5 yearsNote that the value that you see in
Send-Q
(the effective backlog size for such socket) might be different from the value set by the user in thelisten(2)
syscall. That's because Linux will make use of/proc/sys/net/core/somaxconn
as a ceiling and change the backlog value based on that (seenet/socket.c#sys_listen
: elixir.bootlin.com/linux/v4.15/source/net/socket.c#L1479) -
user207421 over 5 years@CiroCosta That's the current size, not the maximum size. It doesn't provide the 'backlog value of that socket (backlog value that was sent to
listen()
call)', which is what was asked for. -
user786 over 2 yearsIs there a way I can change the running server backlog value in c code. Some system call or kernel hook or ioctl or something. Or the only solution is to close socket and start listening again which I think probably used in server I may be wrong