createCheckoutSession function very slow
See original GitHub issueBug report
firestore-stripe-subscriptions
Describe the bug
When clicking on the button in my app that should take the user to the Stripe checkout page, it takes anywhere from 500-5000 ms to redirect the user. Most of the time it takes for the user to be redirected is from the time it takes the createCheckoutSession to run. As well, the function can have up to 6 seconds of latency according to Firebase logger.
Expected behavior
I wish the program ran way faster.
Screenshots
System information
- OS: Windows 10
- Browser: Microsoft Edge (tested on all browsers)
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Initiating multiple (many) Stripe Checkout sessions at the ...
This will make your page very slow as you have many requests to the Stripe API creating many Checkout Sessions, most if not...
Read more >Magento 1.9 checkout and cart very slow
Often, cart functions are not cached for obvious reasons (changing content throughout the process) and therefore an FPC does not make up for...
Read more >Stripe is very slow. Suggestions what to do ? : r/stripe - Reddit
Upon logging in on the web app, I trigger a (google) cloud function to fetch the user and its subscription plan. This step...
Read more >Create a Checkout Session – curl - Stripe API reference
A valid billing address, billing name and billing email are required on the payment method for Checkout to prefill the customer's card details....
Read more >8 ways to speed up your Ansible playbooks | Enable Sysadmin
Here's how to optimize your Ansible playbooks to make them run faster ... The output details the time it took for each task,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Can you all who are seeing an increased latency open a support ticket with Cloud (GCF specifically) and mention this issue? Each case might need a different resolution and the support team can help you there. I’m not sure if this is Stripe related or GCF related but we can help identify that with a better analysis.
For anyone trying to diagnose this, I’m pretty sure this all boils down to the same issue that has long plagued Cloud Functions. Cold start times are ridiculously long, not at all suitable for production, and Google has been aware and unable to fix for over two years now. Minimum instances somewhat mitigates the issue but it’s merely a bandaid that doesn’t actually fix the problem because cold starts are unavoidable in practice, no matter how consistent your traffic is.
https://issuetracker.google.com/issues/158014637
One thing that we have seen recommended and implemented for our own functions that does seem to make a noticeable improvement, is to raise the memory allocation from the default 256 MB to 1 GB or more. The memory itself doesn’t make any difference but the CPU scheduling Google uses under the hood is dependent on the memory configuration. The default 256 MB grants your function 400 MHz CPU cycles, whereas 1 GB gets you 1.4 GHz, 2GB 2.4 GHz, and 4GB 4.8 GHz. These higher CPU clock speeds noticeably reduce our cold start times. It’s still not ideal but it’s a big help not well documented by Google.
https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation