ror-community / ror-roadmap

Central information about what is happening at ROR and how to contribute feedback
10 stars 2 forks source link

[BUG] First request takes 20 seconds? #270

Open bchu1 opened 3 weeks ago

bchu1 commented 3 weeks ago

Version v1

Describe the bug Seems like the first request I make (https://api.ror.org/organizations?query=a for example) takes 20 seconds, while subsequent requests (even for the same query) are pretty fast. Tried across browsers, incognito, and different apps, was only able to see it happen the first time. Others on our team were also able to reproduce the 20 second initial delay.

To Reproduce Steps to reproduce the behavior:

  1. Make an initial request to https://api.ror.org/organizations?query=a
  2. Notice 20 second delay.
  3. Make another request, no delay.

Expected behavior No delay.

Screenshots N/A

Device information:

Additional context N/A

lizkrznarich commented 3 weeks ago

Hi @bchu1 looking at our ElasticSearch and load balancer metrics, I don't see any unusual latency in the past week. Load balancer response time over the past week is stable at around 2 sec.

Running your example query in Firefox and Chrome this afternoon, I got about 8 sec and 1 sec total response time respectively (this is different from the load balancer response time bc it includes time that the browser spends doing other parts of the process). I also got a response time of ~1 sec in the command line via cURL using curl -s -o /dev/null -w "%{time_starttransfer}\n" 'https://api.ror.org/organizations?query=a'.

I'm a little stumped as to why you're seeing this behavior. Browser caching would explain the quick response to subsequent queries that are the same, but it wouldn't explain the very long initial response time. Is it possible that your organization has network or endpoint security monitoring that inspects inbound and/or outbound requests?

Otherwise, it would be helpful if you could pop open your Developer Tools and take a screenshot of the network request and response, like the ones I've attached below. In Chrome, this is under View > Developer > Developer Tools and in Firefox, it's under Tools > Web Developer > Network.

Also, what's shown in the "time_taken" field in the query response in the case where it takes a long time? This is the number of milliseconds ElasticSearch spent processing the query, which is different from how long it took for the response to get to you, but it's helpful to know regardless.

Screen Shot 2024-10-29 at 1 12 15 PM Screen Shot 2024-10-29 at 1 13 43 PM