Back

[SOLVED] Speeding up Appwrite Cloud Function execution

  • 0
  • Web
  • Databases
  • Realtime
  • Self Hosted
  • Functions
Drake
13 Oct, 2023, 16:23

FYI, im on cloud and i have a function that only creates a document after some validation. cold start takes 4s but after that it's .5s

TL;DR
Title: [SOLVED] Speeding up Appwrite Cloud Function execution Solution: The user resolved their issue by awaiting the promise and displaying a loading animation while the function processes. They also disabled the "Create" button during the promise and closed the modal once it resolved. Additionally, they mentioned considering network latency and suggested adding log messages to track slow parts of the code. They provided a link to their app and source code for further reference. The user also mentioned updating dependencies and suggested trying deleting node_modules and running `npm i` again.
larkx
13 Oct, 2023, 16:26

Wait, I'm slightly confused, am i updating the front end appwrite dependency or the functions dependency? (I'm new to this)

Drake
13 Oct, 2023, 16:28

front end. that's what's calling the createExecution(), right?

larkx
13 Oct, 2023, 16:28

Yes, that makes sense.

larkx
13 Oct, 2023, 16:28

I think what's really confusing me is that my package.json tells me different to npm -v appwrite

larkx
13 Oct, 2023, 18:25

Any idea on how to speed mine up? Is it just down to my code not being optimised or because it's JS

Drake
13 Oct, 2023, 18:37

mine is a node function πŸ€·πŸΌβ€β™‚οΈ

larkx
13 Oct, 2023, 18:37

Huh, what programming standards do you usually use?

Drake
13 Oct, 2023, 18:37

you can try deleting your node_modules and then running npm i again

Drake
13 Oct, 2023, 18:38
Drake
13 Oct, 2023, 18:40

oh looks like im not fetching the user πŸ˜…

Drake
13 Oct, 2023, 18:40

what you could also do is add log messages for the timing of things to see what parts are slow

Drake
13 Oct, 2023, 18:41

and of course network latency (distance from the server) can play a factor too

larkx
13 Oct, 2023, 18:47

I'll try speed up the code, but I'll also implement it so that the "Create" UI button is disabled whilst the promise is awaited, then once it's resolved, I can close the modal. (Inspiration... Appwrite Cloud lol)

larkx
13 Oct, 2023, 18:48

That way it looks like something is happening in a UX sense

Drake
13 Oct, 2023, 18:56

yep this is always a good idea

larkx
13 Oct, 2023, 23:37

Woah

larkx
13 Oct, 2023, 23:37

No idea how

larkx
13 Oct, 2023, 23:37

barely changed the code but..

D5
14 Oct, 2023, 09:02

Wow that's fast!

D5
14 Oct, 2023, 09:02

Can I mark this as solved then? <:appwriterocket:823996226894692403>

larkx
14 Oct, 2023, 09:43

Yeah I reckon so, I think that speed was an outlier

larkx
14 Oct, 2023, 09:44

But, I have settled on awaiting the promise to resolve and just showing a loading animation on the create button whilst the function processes

D5
14 Oct, 2023, 10:17

Perfect

D5
14 Oct, 2023, 10:17

[SOLVED] Speeding up Appwrite Cloud Function execution

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more