Skip to content

Improve start-up time by not loading unused modules #9389

Open
@oallouch

Description

@oallouch

New Feature / Enhancement Checklist

Current Limitation

Because parse-server is compiling a lot of unused dependencies (Live Queries, Postgres, redis, ...), the startup is slow.
It prevents us from using Parse in cheap configurations of serverless hosting solutions, like Google Cloud Run with min-instances=0 .

Feature / Enhancement Description

Feature request : a fast startup,
prevent those unused dependencies from compiling, maybe by putting the imports inside conditions. For instance :

static async createLiveQueryServer(
    httpServer,
    config: LiveQueryServerOptions,
    options: ParseServerOptions
  ) {
    if (!httpServer || (config && config.port)) {
      var app = express();
      httpServer = require('http').createServer(app);
      httpServer.listen(config.port);
    }
    import { ParseLiveQueryServer } from './LiveQuery/ParseLiveQueryServer';
    const server = new ParseLiveQueryServer(httpServer, config, options);
    await server.connect();
    return server;
  }

Example Use Case

You're starting a new project. With a fast startup, you can have a nice server (4 Go and 2 CPUs) for almost nothing.
On Cloud Run, the CPU is turned off between requests, you only pay for the RAM, and after 15 minutes, the instance is unmounted. Add to this the fact that, in a month, 60 CPU-hours are free and 125 Go-hours are free.
But for this, you need to be able to have a fast startup. In my current project, a cold restart takes approximately 12 seconds. I think we could reach a few seconds.

Alternatives / Workarounds

I can put the min-instances to 1. When a second or third instance is started, Cloud Run waits before sending requests.
And between requests, when there's no CPU, you only pay for RAM and a special fee for "inactive instances".

Details

Here's a startup profile with all the unnecessary compiled code in red (at least 70% of all the compiled code).
It's on my big local machine. On the server, all time are multiplied by 4, at least.

There might be another problem : all the schemas are loaded at once to build the cache, but let's stick with the compilation issue for now :)

thx

Parse-server-startup

Activity

parse-github-assistant

parse-github-assistant commented on Oct 29, 2024

@parse-github-assistant

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!
mtrezza

mtrezza commented on Oct 29, 2024

@mtrezza
Member

I'm closing this as it does not seem to be bug report or a feature request.

oallouch

oallouch commented on Oct 29, 2024

@oallouch
ContributorAuthor

I thought it would be a nice feature to communicate about.
Serverless is everywhere and being able have a very powerful server very cheap, for me, is a feature.

mtrezza

mtrezza commented on Oct 29, 2024

@mtrezza
Member

Was this indeed a feature request? Could you please edit your initial post by using the template provided when opening an issue to help clarify what specific feature you are requesting? Then we can re-open this.

oallouch

oallouch commented on Oct 31, 2024

@oallouch
ContributorAuthor

I would like to try and do it myself, but I'm on Windows and it doesn't look like it's supported.

added
type:featureNew feature or improvement of existing feature
type:questionSupport or code-level question
and removed
type:questionSupport or code-level question
type:featureNew feature or improvement of existing feature
on Oct 31, 2024
mtrezza

mtrezza commented on Oct 31, 2024

@mtrezza
Member

Thanks for editing the post and using the template. It sounds like you'd suggesting to speed up the start time of Parse Server. A start-up time that is fast enough for you may not be fast enough for someone else, so in order to keep this open as a feature request, we'd need to specify an objective goal or metric by which the issue can be considered closed. For example, we already have open feature requests to move Postgres, GraphQL and other adapters out of the Parse Server code base. Or is there a quicker approach you are suggesting to implement in the meantime? Could Parse Server be optimized by just not loading certain modules in code if they are not configured in Parse Server? That would make sense I guess and probably shouldn't be too difficult to implement?

@Moumouls has experience with Parse Server running on serverless, maybe he has some input here?

changed the title [-]Parse can't go 0 instance due to slow startup time[/-] [+]Improve Parse Server start-up time by not loading unused modules[/+] on Oct 31, 2024
changed the title [-]Improve Parse Server start-up time by not loading unused modules[/-] [+]Improve start-up time by not loading unused modules[/+] on Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:questionSupport or code-level question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @oallouch@mtrezza

        Issue actions

          Improve start-up time by not loading unused modules · Issue #9389 · parse-community/parse-server