Best way to have another API access the same Parse data?

We are implementing some functions that are very computationally intensive (machine learning inference). We don’t want to block the Parse from serving the app while these functions run.

The options I was considering:

  1. Run another api with access to the same data but on a different server. Then when these functions are required simply call those end points on the other server and have them add the end result to the Parse database.

  2. Have another server that can’t access any data from Parse. It then has an api which requires the entire payload of data from our main app. Have a cloud function which accepts the end result and populates it into Parse.

If I go with (1) would it be possible to run a separate Parse app that connects to the same data? It would basically mirror the main parse app except that it would have different cloud code for these long-running functions.

If I go with (2) in some ways it could be simpler because it could run on something like AWS Lambda. But it would require passing a lot of data back and forth to our main Parse app.

In testing option (1) I can get a 2nd instance of parse-server to connect to the same database. Are there any possible issues with this?

What’s the best way to get the 2 instances to communicate with each other? (e.g. call cloud code of one server instance from the cloud code of a different server instance)

İ don’t think so. That’s basically horizontal scaling.

İ would choose option 1

2 Likes

Parse server instance is stateless. and you can run as many as instances you want and connect them to the same database for the same app (this is actually how do you scale horizontally for better performance and coverage) so there will be no issues sticking to the first option
but for the second option

Have another server that can’t access any data from Parse. It then has an api which requires the entire payload of data from our main app.

this is not true actually your AWS lambda function its just like any other client calling your Parse server instance. so you can call the required data inside your AWS lambda function via REST API or by using JS SDK of parse and do your heavy computations

2 Likes

Thanks for the reply.

Good to know about how the horizontal scaling works :slight_smile: