parse-community / parse-community/parse-server

Improve start-up time by not loading unused modules

Open
#9,389 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:question
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue identifies createLiveQueryServer and ./LiveQuery/ParseLiveQueryServer as starting points; first trace how Live Query, Postgres, and Redis modules load during Parse Server startup. Compare startup profiling before and after, keeping the separate schema-loading concern out of scope. Done means unused dependencies are not loaded for configurations that do not use them and cold-start time improves.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, javascript, nodejs
Domain
backend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.