calcom / cal.com

Scheduling infrastructure for absolutely everyone.
https://cal.com
Other
31.69k stars 7.71k forks source link

[CAL-119] Initial rendering of calendar takes 3-5 seconds! #4535

Closed timfee closed 1 year ago

timfee commented 2 years ago

See image -- on a fast connection, with a single calendar configuration -- painfully slow.

Screenshot_2022-09-16_09-09-20_1o326Lzi

PeerRich commented 2 years ago

can you post the link here?

timfee commented 2 years ago

https://cal.com/tim/15

ciaranha commented 1 year ago

related: https://linear.app/calcom/issue/CAL-281/10-seconds-load-time-for-availability

ciaranha commented 1 year ago

Update from @emrysal

I think that's a bad ticket - it's been improving slowly ever since that was assigned to me but I'm not sure what is possible and it's continual improvement

Tom-Potanski commented 1 year ago

We also experience this issue. A lot. @Jaibles

PeerRich commented 1 year ago

we have an ongoing task to improve performance of this. the main issue is that the cold boot of serverless functions is slow. this gets better if your app is used more frequenlty -- i know not a perfect solution. we're trying to find a way to do this without cold boot

PeerRich commented 1 year ago

note to self: https://cal.com/peer/30min is faster, surprisingly

leerob commented 1 year ago

What API is it using? What file? Random guess: https://github.com/calcom/cal.com/blob/main/apps/web/pages/api/book/event.ts

You might consider using Edge API Routes, which will help you get faster cold startups: https://nextjs.org/docs/api-routes/edge-api-routes

export const config = {
  runtime: 'edge',
}

export default async function handler(req: Request) {
  return new Response()
}

But I think would need to verify this is possible with next-auth.

lukasklein commented 1 year ago

note to self: https://cal.com/peer/30min is faster, surprisingly

the getSchedule request for your calendar takes almost 3s for me to complete as well

image
~ ❯ time curl 'https://cal.com/api/trpc/viewer.public.slots.getSchedule?batch=1&input=%7B%220%22%3A%7B%22json%22%3A%7B%22eventTypeId%22%3A127%2C%22eventTypeSlug%22%3A%2230min%22%2C%22usernameList%22%3A%5B%22peer%22%5D%2C%22startTime%22%3A%222023-01-02T23%3A00%3A00.000Z%22%2C%22endTime%22%3A%222023-01-31T22%3A59%3A59.999Z%22%2C%22timeZone%22%3A%22Europe%2FBerlin%22%2C%22duration%22%3Anull%7D%2C%22meta%22%3A%7B%22values%22%3A%7B%22duration%22%3A%5B%22undefined%22%5D%7D%7D%7D%7D' > /dev/null --compressed
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1394    0  1394    0     0    684      0 --:--:--  0:00:02 --:--:--   686
curl  --compressed > /dev/null  0.02s user 0.01s system 1% cpu 3.048 total
leerob commented 1 year ago

Woah.

In this release, we have decreased the size of our engine files by an average of 50%. The size of the Query Engine used on Debian, with OpenSSL 3.0.x, for example, went from 39MB to 14MB. We will also remove some smaller engines to decrease the total size in future versions.

https://github.com/prisma/prisma/releases/tag/4.8.0

You might want to update! (Assuming this API route uses Prisma)

PeerRich commented 1 year ago

@lukasklein

the getSchedule request for your calendar takes almost 3s for me to complete as well

well 3 seconds is still better than 5 to 10 seconds (which we have seen too)

PeerRich commented 1 year ago

anyone interested in this, we're making a bit of progress. stay tuned.πŸ™

PeerRich commented 1 year ago

we have identified that one of the slowness reasons is a slow caldav server for the affected users.

we can still improve prisma and cold boots tho

PeerRich commented 1 year ago

/bounty $1000 per second

algora-pbc[bot] commented 1 year ago

πŸ’Ž $1,000.00 bounty created by PeerRich πŸ‘‰ To claim this bounty, submit a pull request that includes the text /claim #4535 somewhere in its body πŸ“ To receive payouts, join Algora and complete the relevant onboarding steps πŸ’΅ Payment arrives in your account 2-5 days after the bounty is rewarded πŸ’― You keep 100% of the bounty award 🌳 If you want, you can donate 100% of the rewards to climate change projects! πŸ™ Thank you for contributing to calcom/cal.com!

roae commented 1 year ago

@PeerRich I have an idea that could solve this, i will submit a pull request soon.

algora-pbc[bot] commented 1 year ago

πŸ’‘ roae submitted a pull request that claims the bounty πŸ‘‰ To accept and/or reward this claim, visit your org dashboard on Algora

algora-pbc[bot] commented 1 year ago

@roae cal wants to reward your solution. Please sign up on Algora, link your Github account and connect with Stripe on your dashboard.

algora-pbc[bot] commented 1 year ago

roae has completed their onboarding. You can now complete the payment on your org dashboard

algora-pbc[bot] commented 1 year ago

πŸŽ‰πŸŽˆ @roae has been awarded $1,000! 🎈🎊

PeerRich commented 1 year ago

we ended up hiring @roae πŸ™

zomars commented 1 year ago

https://cal.com/tim/15

@timfee we just released Data Proxy. Can you verify if it's still slow?

timfee commented 1 year ago

See attachment. Still seems like it's a bit slow, but better than before!

https://user-images.githubusercontent.com/3246342/225504906-9a1148e1-7913-4d4a-a92e-381b31428fd0.MOV