You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to better understand the latency issues I experience. This is my current setup:
My nextjs app is deployed on Vercel [Hobby]
On nextjs I have the API endpoint /api/graphql where an ApolloServer is created
My data source is a MongoDB running on a root server in Frankfurt (Germany)
Some pages use getStaticProps others getServerSideProps
I made some tests, where I used Postman to access the GraphQL endpoint:
Running a very simple query (without accessing my MongoDB) I see a response time of ~180ms
Running a query where a MongoDB query is executed I see a response time of ~350ms
I assume this is due to the fact that the enpoints are deployed to the region sfo (San Francisco)? So on 1. the execution is me -> SFO -> me and on 2. it is me -> SFO -> FRA -> SFO -> me. So when getStaticProps or getServerSideProps are executed this will happen as well in sfo? This is a big issue in case of getStaticProps the build time will take quite a while when 1000s of pages need to be created and in case of getServerSideProps the First Byte will be terrible.
So what options do I have?
I move the Serverless Functions closer to Frankfurt, for this I need to switch to a Pro plan?
Drop the /api/graphql endpoint and setup a GraphQL server in Frankfurt. I guess this will not fix the latency, since getStaticProps or getServerSideProps will be still executed in sfo.
Move my MongoDB closer to San Francisco (which is not an option)
Any further ideas how to tackle this latency issue?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I would like to better understand the latency issues I experience. This is my current setup:
ApolloServer
is createdgetStaticProps
othersgetServerSideProps
I made some tests, where I used Postman to access the GraphQL endpoint:
I assume this is due to the fact that the enpoints are deployed to the region sfo (San Francisco)? So on 1. the execution is
me -> SFO -> me
and on 2. it isme -> SFO -> FRA -> SFO -> me
. So whengetStaticProps
orgetServerSideProps
are executed this will happen as well in sfo? This is a big issue in case ofgetStaticProps
the build time will take quite a while when 1000s of pages need to be created and in case ofgetServerSideProps
the First Byte will be terrible.So what options do I have?
getStaticProps
orgetServerSideProps
will be still executed in sfo.Any further ideas how to tackle this latency issue?
Beta Was this translation helpful? Give feedback.
All reactions