By using AWS re:Post, you agree to the Terms of Use

Latency in GET requests



I wrote a code in Python that extracts data from the FTX exchange using their API. I am running the code in an AWS instance (free plan, t2.micro), located very closeby to the servers of the exchange.

The code is essentially an infinite loop. At each step, it sends 3 'GET' requests, elaborates the response, and then goes to the next step. For the first few hundred iterations, the latency (defined below at the end of the post) for each block of three requests is of the order of 0.3seconds. After some time, it starts to grow up, reaching values from 2 to 5 seconds. In my local computer, located in the US, the latency is pretty constant at 1 second. There are no ratelimits in the FTX API for GET requests, so I should not expect any limit from the server. Is AWS limiting the rate of GET requests that I can make?

I am trying to understand the origin of this extra-latency. To do so, I have monitored the https data traffic with tcpdump and I have modified the python script so that it stops as soon as it experiences a latency > 2 seconds. In this way, I can isolate the last packets in the tcpdump output and try to understand the origin of the delay.

However, I really don't know how to read the output (I uploaded it here Can anyone help me to understand the origin of the latency? is the IP of FTX server is the IP of the machine where my code runs

Definition of latency used here: I post the relevant part of the code where I compute the latency

for pair in pairList:  # pairList  = ['BTC/USD','ETH/BTC','ETH/USD']
return latency

So, it is the total sum of the latency returned by the requests.get for each request.

1 Answer

T-series instances use a concept of "burstable" performance where the instances has a number of CPU credits; when busy these are used; when idle credits build up. If there are no credits then the performance of the instance returns to a (lower) baseline. What you might be seeing is that you're running out of CPU credits. You can monitor the CPU credits so that might be worthwhile checking.

If this is causing the latency you might consider other instance types that do not use CPU credits (which is every other instance type) or you can enable Unlimited mode - noting that both of these solutions will have extra costs; and if you're using Unlimited mode all the time it it's best to consider a non-burstable instance type.

profile picture
answered 14 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions