mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
101 stars 53 forks source link

Performance On Cart Page #816

Open sprankhub opened 3 weeks ago

sprankhub commented 3 weeks ago

Describe the bug We're working on some TTFB improvements. So while benchmarking the cart page, we found that a curl_exec from Mollie takes almost 300 ms:

curl_exec(https://api.mollie.com/v2/methods?...amount[value]=...

This comes from \Mollie\Payment\Model\MollieConfigProvider::getConfig. Could this somehow be improved? Do we really need to get the payment methods there? Could this be postponed to a later point or be done asynchronously?

Please mind that we use Hyvä / Hyvä Checkout, but when checking the code, even in Luma, the checkout config is loaded in the cart, so it should be the same.

Used versions

To Reproduce Steps to reproduce the behavior:

  1. Go to the cart page
  2. Analyse how long \Mollie\Payment\Model\MollieConfigProvider::getConfig takes to execute.

Expected behavior \Mollie\Payment\Model\MollieConfigProvider::getConfig just takes a few milliseconds.

Actual behavior \Mollie\Payment\Model\MollieConfigProvider::getConfig takes almost 300 milliseconds.

Screenshots

image

Additional context n/a

Frank-Magmodules commented 3 weeks ago

Thanks, as always, for sharing a potential improvement @sprankhub! We’ll review the issue and get back to you soon.

sprankhub commented 3 weeks ago

Thanks, @Frank-Magmodules.

By the way, on the checkout page itself, the call took 400 ms in my test. We surely need it there, but maybe Mollie could also improve the response times of their API :face_with_peeking_eye:

Frank-Magmodules commented 3 weeks ago

Hi There @sprankhub ,

You're right, making that call on the shopping cart page doesn’t make much sense, as the output isn’t actually used there. However, I believe this is more of an issue with how Magento is set up rather than a "Mollie" problem. That said, we have a solution planned for the next release, which will prevent the call from being made on the cart page!

Regarding the comment about the speed of the API call itself: that’s not something I can address directly, but I’ll pass the feedback on to the Mollie team.

I’ll keep the issue open until we’ve released the new version with this improvement. Thanks again!

fjbender commented 3 weeks ago

I'll see if we can take a look at the endpoint's speed.

In the meantime, other integrations have the possibility to turn off usage of the Methods API. This could also be a solution here, but it would require users to manually configure the available countries and limits. Especially for larger or performance-critical setups this could help, though.

What do y'all think?

sprankhub commented 3 weeks ago

Thanks for checking, @fjbender!

I wouldn't mind that the available countries and limits need to be configured in the Magento backend, but that's just my two cents :)

Frank-Magmodules commented 3 weeks ago

Great additions, guys! I’ll discuss the best approach with the team, but it looks like we’re all on the same page! 😉