I’ve recently noticed calls to `/sessions/whoami` ...
# ory-network
m
I’ve recently noticed calls to
/sessions/whoami
latency has increased to ~450ms. We have the Edge Sessions setting enabled and are on an Essentials plan (and based in NZ). Is this to be expected?
Postman screenshot
h
Hm no, it also appears that the correct headers are set. What’s your project slug?
oh and keep in mind that some requests will be slower, for example when the cache was not hit. if you reload the session 2-3 times it should hit the cache again
s
do you know when exactly the latency increased?
h
It looks like the cache works. I think the problem is that you probably don’t have enough traffic on your staging system for the cache to be truly effective. The more the cache is used / hit, the better it will perform.
m
Sorry for the slow reply, timezone differences… Project slug is eloquent-goldberg-u1v25wua4k.projects.oryapis.com, but we are using CNAME auth.staging.amlify.com. I’m not sure when the latency increased, I am testing something new and noticed the overall response times had gone back up to ~450ms (from ~50ms after caching was introduced). At what traffic volume will effective caching kick in?
s
Requests are cached on an individual basis, so it should not matter. I'd recommend you send the same request multiple times and watch the response headers, they should indicate whether the cache was hit. In the end it depends on how cloudflare routes them, but typically if you don't switch networks it should be the same edge data center
m
Hmmm, 20 sequential requests still gives me
Ory-Session-Edge-Status: MISS
in every response.
h
Hm, that’s quite strange - when are you available so we can investigate together? It’s easier synchronous. The yellow lines in the chart above mean by the way that the cache served the request. So we see that several requests are served from cache.#
m
I’m available NZDT 0730h - 2130h.
Thank you
Perhaps the latency is due to the closest Cloudflare node being too far from NZ? We see the same latency when host services in Singapore. Typically NZ traffic is routed through Perth then on to Singapore.
h
oh that could be possible 😞
Hm, cloudflare says they have datacenters in NZ: https://www.cloudflare.com/en-gb/network/
Is Ory-Session-Edge-Status always miss for you?
Can you create an account for me or enable registration on staging so i can check myself?
By the way, we are also in the process of a global roll out to multiple data centers. Then, even if you don’t hit the cache, the latency will go down significantly
But it takes time to do this 😅
m
Yes, from the response headers I am always getting
Ory-Session-Edge-Status: MISS
. I have enabled registration in our staging environment.
h
Oh wait, you’re using session tokens
It only works for session cookies at the moment 😞 https://www.ory.sh/docs/concepts/cache#caching-strategy
Because session tokens are not yet stateless/idempotent
m
Thank you. I wouldn’t have thought to look at that. Do you have plans for caching by session token or is that more of a “wait for the regional data centre rollout” thing?
h
No we definitely want to solve that, but we are first improving the APIs for native which then also will roll out with a way to refresh session tokens, which then makes idempotent tokens possible 🙂 And then we can enable the cache here as well
The problem is that we can easily refresh cookies in the browser, but for api clients you need business logic on the consumer side …