Skip to content

Parse cluster not working properly #6894

Closed

Description

@simonegiacco

I'm trying to start parse server in a cluster of 3 instances (4 cores, so N - 1)

Setting the "cluster" parameter when creating new ParseServer() is not working
I tried with an app using [email protected] and with a clean installation of parse-server-example using latest parse-server without success;

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppId',
  cluster: 3, //. <==== HERE! also tried cluster:true
  masterKey: process.env.MASTER_KEY || '',
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse'  
});

Using this setting, ps -aux | grep node shows one node instance

I've tried with parse-server CLI and the clustering is working properly:

parse-server --appId X --masterKey X --databaseURI mongodb://localhost:27017/dev --publicServerURL http://localhost:1337/parse  --cluster=3

Using this command, ps -aux | grep node shows three node instances.

Is this a bug or am I doing something wrong?

Activity

  1. mtrezza commented on Sep 3, 2020

    @mtrezza
    Member

    Setting the "cluster" parameter when creating new ParseServer() is not working
    I've tried with parse-server CLI and the clustering is working properly

    This is expected and it may be more obvious when you think about it this way:

    • Starting Parse Server via the CLI parse-server --cluster=true ... does not immediately create and start a Node.js Parse Server instance. It is merely telling the Parse CLI that you want to launch a Parse Server instance. The CLI acts as an intermediary and looks at the cluster option to launch multiple Parse Server instances.

    • Starting Parse Server via Node.js const api = new ParseServer(...); express().use('/parse', api); means you are directly creating and launching a Parse Server instance. There is no intermediary who looks at the cluster option. So it would be up to you to launch multiple Parse Server instances using the Node.js cluster package which provides an example.

    @dplewis Just to make sure, did I get this right?

  2. TomWFox commented on Sep 12, 2020

    @TomWFox
    Contributor

    I'm closing this as there has been no further response, let us know if you still have any questions/issues.

  3. rdhelms commented on Jul 23, 2021

    @rdhelms

    @mtrezza @TomWFox Just to clarify - the conclusion here was that using the cluster option has no effect when using new ParseServer(...)?

    Could that be updated somewhere in the docs? The ParseServerOptions docs mention the cluster option in a way that certainly implies that it does something when used with new ParseServer(), but attempting to understand its impact is what led me here.

  4. mtrezza commented on Jul 23, 2021

    @mtrezza
    Member

    Such a note would be welcome.

    You are correct. The cluster option is in the Parse Server Options docs because usually (probably all other) options can be set either via the Parse Server CLI or via the Parse Server object. cluster is an exception and can only be set via the CLI, as it needs the CLI intermediary logic to spin up multiple Parse Server instances.

    Please feel free to add a comment to the options definitions. We do not have a way in the docs to specify "CLI only" options, so a comment there should be fine. The change would be made in this parse-server repo in the options definitions. Remember to run npm run definitions and npm run docs afterwards. You can reference this issue in your PR.

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

      Issue actions