I have struggled with API of https://api.materialsproject.org recently. Because it is so slow and unstable when fetching data. I thought it was just the problem of this site. However, I found it is not true today.
I always work on my laptop which is connected to a wifi router. I just happened to try another computer with an ethernet connection, and I found it fetches data fast!
So I made a ping test on my laptop.
Disable wifi and insert the network cable, I got
PING api.materialsproject.org (104.18.41.120) 56(84) bytes of data.
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=1 ttl=54 time=136 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=2 ttl=54 time=134 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=3 ttl=54 time=137 ms
remove cable, and insert the same cable into wifi router, and connect laptop to this wifi router, I got
PING api.materialsproject.org (104.18.41.120) 56(84) bytes of data.
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=4 ttl=44 time=303 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=6 ttl=44 time=301 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=9 ttl=44 time=301 ms
Wow, this is really impressive, an immediate 200ms delay. To rule out the possibility that I may have a bad wifi, I tried another wifi router, still 300ms!
This really perplexed me, because my wifi is actually very fast tested by https://www.speedtest.net, which gives
An even weirder thing is that my work place has an AP network. If I connect to this AP network, I got a fast ping
PING api.materialsproject.org (104.18.41.120) 56(84) bytes of data.
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=1 ttl=54 time=134 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=2 ttl=54 time=135 ms
64 bytes from 104.18.41.120 (104.18.41.120): icmp_seq=3 ttl=54 time=135 ms
However, according to speedtest, this AP network is much slower!
Can somebody explain what is going on? Is there a way to decrease my ping time to api.materialsproject.org via wifi connection?
PS:
As suggested by Martin, I ping the gateway, and I got
Pinging 192.168.31.1 with 32 bytes of data:
Reply from 192.168.31.1: bytes=32 time=1ms TTL=64
Reply from 192.168.31.1: bytes=32 time=2ms TTL=64
Reply from 192.168.31.1: bytes=32 time=2ms TTL=64
Reply from 192.168.31.1: bytes=32 time=3ms TTL=64
Ping statistics for 192.168.31.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 3ms, Average = 2ms
As suggested by petitradisgris, I run tracert api.materialsproject.org
when connected to wifi and got
Tracing route to api.materialsproject.org [104.18.41.120]
over a maximum of 30 hops:
1 3 ms 2 ms 1 ms XiaoQiang [192.168.31.1]
2 3 ms 3 ms 3 ms 172.16.24.1
3 6 ms 6 ms 3 ms 120.199.21.1
4 5 ms 5 ms 5 ms 221.131.254.53
5 * * * Request timed out.
6 * 7 ms 6 ms 111.24.10.169
7 28 ms 28 ms 29 ms 221.183.118.37
8 32 ms 28 ms 28 ms 111.24.17.161
9 32 ms 35 ms 34 ms 221.176.21.190
10 33 ms 37 ms 34 ms 221.183.25.202
11 33 ms 54 ms 32 ms 221.183.55.109
12 203 ms 204 ms 204 ms 223.120.12.213
13 218 ms 217 ms 217 ms 223.120.6.218
14 362 ms 368 ms 364 ms 223.119.64.110
15 307 ms 316 ms 306 ms 172.70.212.2
16 * 309 ms * 104.18.41.120
17 301 ms * 301 ms 104.18.41.120
Trace complete.
Then I run tracert api.materialsproject.org
with only cable connected
Tracing route to api.materialsproject.org [104.18.41.120]
over a maximum of 30 hops:
1 2 ms 2 ms <1 ms 172.16.24.1
2 27 ms 7 ms 6 ms 61.153.0.129
3 * * * Request timed out.
4 * * 2 ms 115.233.18.21
5 * * 4 ms 202.97.101.189
6 7 ms 7 ms 7 ms 202.97.64.182
7 * 7 ms 7 ms 202.97.50.193
8 142 ms 146 ms 143 ms 202.97.71.198
9 209 ms 267 ms 220 ms 218.30.53.214
10 168 ms 157 ms 158 ms 172.68.188.22
11 135 ms 135 ms 134 ms 104.18.41.120
Trace complete.
PS
Now I came back home. I can test yet on another wifi router, and this one is expensive :)
Surprisingly, the ping also takes 300ms. Trace are below
Tracing route to api.materialsproject.org [104.18.41.120]
over a maximum of 30 hops:
1 1 ms 10 ms <1 ms RT-AX86U-0158 [192.168.50.1]
2 2 ms 1 ms 1 ms SMBSHARE [192.168.1.1]
3 6 ms 4 ms 4 ms 10.109.128.1
4 5 ms 4 ms 6 ms 221.131.254.41
5 * * * Request timed out.
6 6 ms 6 ms 7 ms 111.24.10.169
7 28 ms 28 ms 28 ms 221.183.118.33
8 31 ms 52 ms 30 ms 111.24.2.250
9 29 ms 28 ms 28 ms 221.176.21.190
10 28 ms 28 ms 27 ms 221.183.52.1
11 36 ms 38 ms 41 ms 221.183.55.109
12 206 ms 208 ms 212 ms 223.120.12.213
13 202 ms 207 ms 209 ms 223.120.6.218
14 445 ms 459 ms 450 ms 223.119.64.110
15 317 ms 318 ms * 141.101.72.32
16 323 ms * * 104.18.41.120
17 * * * Request timed out.
18 * * * Request timed out.
19 312 ms 305 ms 313 ms 104.18.41.120
Trace complete.
Still takes a complicated route. So I came up another question. Since we already know there is a shortcut to the server, is it possible to force wifi to take the best route?