Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Results 1 to 8 of 8
  1. #1
    Join Date
    June 2005
    Location
    Germany
    Posts
    124

    tcp query -> issue: delay between reply of lines

    Hi,

    iam trying to speed up the TSViewer, so yesterday ive spent some time profiling it to find out what takes so long when i query an server and to shorten the time it takes if possible. Ive checked in already with ScP and he advised me to open a thread about it. Here it is.

    I found, the cause are the replies from the TS3 server itself. Ive commenced a small testing and integrated debug timing lines into the console output. The findings are suprising for me. I would like to talk about this with you guys. Please take a look at the following test results.

    First the connection to the server is being established, the server type verified ("TS3"), the virtual server selected and then, to have uniform results, the same command ("serverinfo") sent 5 times. After every command the data line is read and then the status line ("error id=0 msg=ok"). I sum and display the timings [ms] of everything below.


    127.0.0.1
    Code:
    0.000 connecting to server
    0.000 connected
    -------------------------------
    0.000 verifying ts3 instance, reading 2 lines
    0.000 reading 'TS3' line
    0.008 reading 'Welcome to TeamSpeak' line
    0.009 verification complete, time needed: 0.008s
    -------------------------------
    0.009 sending CMD: use port=9987 
    0.009 waiting/reading one line
    0.010 read complete, time needed: 0.001s
    -------------------------------
    0.010 sending CMD: serverinfo 
    0.010 waiting/reading one line
    0.010 read complete, time needed: 0.000s
    0.010 waiting/reading one line
    0.010 read complete, time needed: 0.000s
    -------------------------------
    0.012 sending CMD: serverinfo 
    0.012 waiting/reading one line
    0.012 read complete, time needed: 0.000s
    0.012 waiting/reading one line
    0.050 read complete, time needed: 0.038s
    -------------------------------
    0.051 sending CMD: serverinfo 
    0.052 waiting/reading one line
    0.052 read complete, time needed: 0.000s
    0.052 waiting/reading one line
    0.090 read complete, time needed: 0.038s
    -------------------------------
    0.092 sending CMD: serverinfo 
    0.092 waiting/reading one line
    0.092 read complete, time needed: 0.000s
    0.092 waiting/reading one line
    0.130 read complete, time needed: 0.038s
    -------------------------------
    0.132 sending CMD: serverinfo 
    0.132 waiting/reading one line
    0.132 read complete, time needed: 0.000s
    0.132 waiting/reading one line
    0.170 read complete, time needed: 0.037s
    -------------------------------
    NET CONNECT (~PING):    0.000s
    NET TS3 VERIFICATION:   0.008s
    NET DATA LINES TOTAL:   0.000s
    NET STATUS LINES TOTAL: 0.152s
    NET TOTAL:              0.160s
    SCRIPT TOTAL:           0.176s

    Observation
    The server delays the reply of each status line by 38ms. The client and the server are on the same host, the IP is in the whitelist file by default.



    Planet TeamSpeak [~ 20ms ping]

    Code:
    0.000 connecting to server
    0.022 connected
    -------------------------------
    0.022 verifying ts3 instance, reading 2 lines
    0.022 reading 'TS3' line
    0.048 reading 'Welcome to TeamSpeak' line
    0.066 verification complete, time needed: 0.043s
    -------------------------------
    0.066 sending CMD: use port=9987 
    0.066 waiting/reading one line
    0.085 read complete, time needed: 0.019s
    -------------------------------
    0.085 sending CMD: serverinfo 
    0.085 waiting/reading one line
    0.106 read complete, time needed: 0.021s
    0.106 waiting/reading one line
    0.161 read complete, time needed: 0.055s
    -------------------------------
    0.163 sending CMD: serverinfo 
    0.163 waiting/reading one line
    0.187 read complete, time needed: 0.024s
    0.187 waiting/reading one line
    0.241 read complete, time needed: 0.054s
    -------------------------------
    0.243 sending CMD: serverinfo 
    0.243 waiting/reading one line
    0.263 read complete, time needed: 0.021s
    0.263 waiting/reading one line
    0.317 read complete, time needed: 0.053s
    -------------------------------
    0.319 sending CMD: serverinfo 
    0.319 waiting/reading one line
    0.341 read complete, time needed: 0.023s
    0.341 waiting/reading one line
    0.397 read complete, time needed: 0.055s
    -------------------------------
    0.399 sending CMD: serverinfo 
    0.399 waiting/reading one line
    0.420 read complete, time needed: 0.021s
    0.420 waiting/reading one line
    0.474 read complete, time needed: 0.055s
    -------------------------------
    NET CONNECT (~PING):    0.0220s
    NET TS3 VERIFICATION:   0.043s
    NET DATA LINES TOTAL:   0.110s
    NET STATUS LINES TOTAL: 0.291s
    NET TOTAL:              0.466s
    SCRIPT TOTAL:           0.481s

    Observation
    It takes about 20ms to get the data line after every command, which is as expected since this is the ping time. But the status lines get delayed by the server.



    USA [~ 200ms ping]

    Code:
    0.000 connecting to server
    0.205 connected
    -------------------------------
    0.205 verifying ts3 instance, reading 2 lines
    0.205 reading 'TS3' line
    0.411 reading 'Welcome to TeamSpeak' line
    0.616 verification complete, time needed: 0.410s
    -------------------------------
    0.616 sending CMD: use port=9987 
    0.616 waiting/reading one line
    0.821 read complete, time needed: 0.205s
    -------------------------------
    0.821 sending CMD: serverinfo 
    0.821 waiting/reading one line
    1.025 read complete, time needed: 0.204s
    1.025 waiting/reading one line
    1.230 read complete, time needed: 0.205s
    -------------------------------
    1.232 sending CMD: serverinfo 
    1.232 waiting/reading one line
    1.436 read complete, time needed: 0.204s
    1.436 waiting/reading one line
    1.639 read complete, time needed: 0.202s
    -------------------------------
    1.641 sending CMD: serverinfo 
    1.641 waiting/reading one line
    1.846 read complete, time needed: 0.205s
    1.846 waiting/reading one line
    2.151 read complete, time needed: 0.305s (network fluctuation)
    -------------------------------
    2.154 sending CMD: serverinfo 
    2.154 waiting/reading one line
    2.357 read complete, time needed: 0.203s
    2.357 waiting/reading one line
    2.561 read complete, time needed: 0.204s
    -------------------------------
    2.563 sending CMD: serverinfo 
    2.563 waiting/reading one line
    2.767 read complete, time needed: 0.204s
    2.767 waiting/reading one line
    2.970 read complete, time needed: 0.203s
    -------------------------------
    NET CONNECT (~PING):    0.205s
    NET TS3 VERIFICATION:   0.41s
    NET DATA LINES TOTAL:   1.02s
    NET STATUS LINES TOTAL: 1.324s
    NET TOTAL:              2.959s
    SCRIPT TOTAL:           2.977s

    Observation
    Here it takes for every line (data & status) the time of the ping time.



    Korea [~ 400ms ping]

    Code:
    0.000 connecting to server
    0.392 connected
    -------------------------------
    0.392 verifying ts3 instance, reading 2 lines
    0.392 reading 'TS3' line
    0.799 reading 'Welcome to TeamSpeak' line
    1.216 verification complete, time needed: 0.824s
    -------------------------------
    1.216 sending CMD: use port=9987 
    1.216 waiting/reading one line
    1.619 read complete, time needed: 0.402s
    -------------------------------
    1.619 sending CMD: serverinfo 
    1.619 waiting/reading one line
    2.030 read complete, time needed: 0.411s
    2.030 waiting/reading one line
    2.438 read complete, time needed: 0.408s
    -------------------------------
    2.440 sending CMD: serverinfo 
    2.440 waiting/reading one line
    2.849 read complete, time needed: 0.408s
    2.849 waiting/reading one line
    3.269 read complete, time needed: 0.421s
    -------------------------------
    3.271 sending CMD: serverinfo 
    3.271 waiting/reading one line
    3.668 read complete, time needed: 0.397s
    3.668 waiting/reading one line
    4.076 read complete, time needed: 0.408s
    -------------------------------
    4.078 sending CMD: serverinfo 
    4.078 waiting/reading one line
    4.487 read complete, time needed: 0.409s
    4.487 waiting/reading one line
    4.896 read complete, time needed: 0.409s
    -------------------------------
    4.898 sending CMD: serverinfo 
    4.899 waiting/reading one line
    5.306 read complete, time needed: 0.408s
    5.306 waiting/reading one line
    5.715 read complete, time needed: 0.408s
    -------------------------------
    NET CONNECT (~PING):    0.392s
    NET TS3 VERIFICATION:   0.824s
    NET DATA LINES TOTAL:   2.033s
    NET STATUS LINES TOTAL: 2.456s
    NET TOTAL:              5.705s
    SCRIPT TOTAL:           5.721s
    Observation
    Same as with the USA server


    Question
    Is this the expected behaviour?

    Thank you for reading.
    Mariusz Bieniek
    http://www.tsviewer.com

  2. #2
    Join Date
    June 2008
    Posts
    18,503
    Maybe some dos protection caues this delay.
    Which server version is this? Did this also appear on server 3.0.10.x ?

    I will talk to the main* server developer after the Tokyo Games show.
    Last edited by dante696; September 11th, 2015 at 04:00 PM.
    When sending me private messages: Please make sure to include reference link to your forum thread or post.

    TeamSpeak FAQ || What should i report, when i open a client thread?

  3. #3
    Join Date
    June 2002
    Location
    Netherlands
    Posts
    1,049
    I think you are experiencing the nagle algorithm https://en.wikipedia.org/wiki/Nagle's_algorithm and our write-write-read pattern. I guess we should enable tcp_nodelay on query to fix this.

  4. #4
    Join Date
    June 2011
    Location
    Germany
    Posts
    4,367
    I noticed that YaTQA runs way faster in SSH tunnel mode (connecting via telnet to 127.0.0.1) than in simple TCP mode. Could that be related?

  5. #5
    Join Date
    June 2005
    Location
    Germany
    Posts
    124
    Interesting read yesterday about the nagle algorithm. Thank you for pointing at that!

    First ive set the TCP_NODELAY option at the client side (php script), but that didnt change anything. It looks like it have to be set on the server, so it does set this option when opening the listening socket as you pointed out.

    Then ive tried the proposed workaround from the wikipedia article to make it a write-read-write-read situation by sending a blank line over the socket after every line read.

    That improved the speed for near servers remarkably.

    localhost from NET TOTAL 0.160s to 0.010s
    planet teamspeak from NET TOTAL 0.466s to 0.271s
    usa and korea unchanged. Reply for each the data and status line was the round trip time.

    Could you compile me a ts3server_linux_amd64 binary with the TCP_NODELAY option set for the query and i test it out?

    Thank you
    Mariusz Bieniek
    http://www.tsviewer.com

  6. #6
    Join Date
    June 2002
    Location
    Netherlands
    Posts
    1,049
    We will add this in our next release. Maybe i can make a beta for this fix soon, but not for at least 2 weeks

  7. #7
    Join Date
    June 2005
    Location
    Germany
    Posts
    124
    Allrighty. Looking forward to it. Thank you.

  8. #8
    Join Date
    June 2008
    Posts
    18,503
    Took a while, but i have news for this.
    Server 3.0.13 will add "tcp_nodelay" option for server query and a beta release is panned for this month.
    When sending me private messages: Please make sure to include reference link to your forum thread or post.

    TeamSpeak FAQ || What should i report, when i open a client thread?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: November 3rd, 2015, 06:51 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •