lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.32k stars 481 forks source link

[Question] Routes Register Slowing Cold Start in Cloud Run #1646

Open brantian opened 1 week ago

brantian commented 1 week ago

Hello!

I'm using Google Cloud Run to deploy my Express server, with routes generated by tsoa.

But I'm having an issue related to cold starts. When a new container is started, registering tsoa routes takes too much time and considerably slows the container startup time. Based on the profiling, it seems that importing the RegisterRoutes is the most time-consuming part.

Are there any approaches I could use to reduce the time it takes to import the RegisterRoutes method and register the routes while starting the Express server?

Thanks!

Sorting

Expected Behavior

Routes are registered fast and don't impact server cold starts.

Current Behavior

Importing the RegisterRoutes function and calling it takes 5 to 6 seconds, in the compiled version.

Context (Environment)

Version of the library: 6.2.1 Version of NodeJS: 18

github-actions[bot] commented 1 week ago

Hello there brantian 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀