nuxt-modules / og-image

Generate OG Images with Vue templates in Nuxt.
https://nuxtseo.com/og-image
360 stars 23 forks source link

the module seems to add significant overhead to unrelated parts of the app #213

Open warflash opened 3 weeks ago

warflash commented 3 weeks ago

I noticed our API response times increased significantly when using the og-image module. On our production instance the difference goes from around ~40ms avg to ~110ms avg depending on whether the module is on or off.

I feel it's difficult to share a proper reproduction, but the perf difference forces us to disable the module entirely

warflash commented 3 weeks ago

So I investigated further and attached flamegraphs below. It seems like https://github.com/harlan-zw/nuxt-schema-org is also affected by this. With both of them disabled everything runs as expected.

I ran a flamegraph perf test of the node server and those are the results for with the 2 modules: Flamegraph download: with-og-schema.cpuprofile image

Both modules disabled: Download: no-og-schema.cpuprofile image

Something about the way the modules use runtime config seems to add a flat 60ms processing time to every route ever visited

harlan-zw commented 6 days ago

Hi @warflash, sorry for the delay on this.

I did an initial investigation and couldn't see anything wrong within the module code. This seems to be related to useRuntimeConfig() not using the cached result between calls, an upstream issue with Nitro.

Could you confirm the Nitro and OG Image versions you're using if it's still an issue for you?