2

When checking for process listening on port using ss command, it's slow when compared with (obsolete) netstat command.

$ time ss -nlp | grep -E ':8081|:8007|:8010'
LISTEN     0      100                      :::8081                    :::*      users:(("java",28681,47))
LISTEN     0      1          ::ffff:127.0.0.1:8007                    :::*      users:(("java",28681,220))
LISTEN     0      100                      :::8010                    :::*      users:(("java",28681,48))

real    0m0.608s
user    0m0.118s
sys 0m0.475s

$ time netstat -nlp | grep -E ':8081|:8007|:8010'
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 :::8081                     :::*                        LISTEN      28681/java          
tcp        0      0 ::ffff:127.0.0.1:8007       :::*                        LISTEN      28681/java          
tcp        0      0 :::8010                     :::*                        LISTEN      28681/java          

real    0m0.146s
user    0m0.012s
sys 0m0.129s

Why is 'ss' slow with '-p' option? Is any alternative way to alleviate slowness in ss?

  • is it really that slow? barely noticeable in real world. plus, you're using grep pipe, which may be slowing the process down. how many tests did you perform? try testing without grep to get better idea of how fast it really is. – Bart Jul 19 '19 at 6:29
  • 1
    @Bart, I experimented this multiple times. Even without any grep also, the result is same with multiple iterations. One of them is as follows: time ss -nlp &>/dev/null; real 0m0.578s user 0m0.099s sys 0m0.462s time netstat -nlp &> /dev/null; real 0m0.137s user 0m0.005s sys 0m0.130s – sungtm Jul 19 '19 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.