I am using parse server as a BAAS for my android app. Everything Is working like a charm, except, when I use the app as a single user intensely I.E. if I send several requests in a very small span of time (refreshing the data many times quickly) from my android client to the parse server, the server freezes. and I get a message back from my cloud function saying: "i/o failure".

I am not getting any info in my parse.logs file related to the issue besides the "i/o failure" message on client-side I would be more then happy to understand the cause for this issue. and I how to resolve it.

Environment Setup

Server

parse-server version: 1.17.3

Operating System: Ubuntu (Bitnami image)

remote server? AWS

Database

MongoDB version: v3.0.9

Localhost

There's a few things you'll want to look at.

1) You're probably using like a t2.micro instance. Those are suited for development / prototyping, but not production. The whole t series is, really. Find the general use one, at least. Though, depending on your use case, others might be better.

2) Optimize your requests. When you refresh in app, cancel open requests instead of letting them complete for naught. try to bundle what you can. Do things in series instead of parallel to minimize concurrent open connections

3) Make sure you properly index your database. parse-server doesn't automatically create indexes, so doing a bunch of queries can reallllly pound your database hard, make it take way longer to get data, which causes the whole server to get backed up. If you're on mlab for your database, open up their console and go to the slow queries tab for the cluster. cmd/ctrl + f - "build index", and build every single one.

To be honest, #1 is a scaling issue. Unless you have a sizeable user base, you should be able to get by with 2 and 3. It sounds like you're doing those reallllly poorly, and your app is trying to do way too much at once that it shouldn't be, and doing what it's doing inefficiently. We used a t2.micro for our server for over a year without issue, though that was with minimum 2 instances on an EB app with auto scaling.

  • Thanks for your detailed response – Hudi Ilfeld Nov 1 at 12:10
  • sorry for the ignorance (I'm pretty new to db's), do u mind elaborating on point 2. meaning, how exactly do I go about closing open connections. is it to do with parse sdk or mongo? and if so could u link me to helpful info topic-related. TIA – Hudi Ilfeld Nov 1 at 14:49
  • I don't know that there's a way to do it for cloud code functions or saves, but queries have a cancel method. So, I imagine that while refreshing, you are making some queries for data? Call the cancel method when the back button is pressed instead of just letting the query run and doing nothing with the data it gets. Also, there's methods like on cloud code Parse.Object.saveAll(). Instead of calling save individually on 5 separate objects, use Parse.Object.saveAll() to save them with one request to your database. – Jake T. Nov 1 at 15:55
  • Furthermore in cloud code maybe you have a bunch of async operations you run all at once. That's time efficient, but not cpu efficient. And, if this function is getting hit many times in rapid succession, it could be what's killing your server, in conjunction with poor indexing which makes each request take longer. So, do things one at a time using async/await (or Promise.then(), but async/await is more modern and easier to read when you get the hang of it. Smaller learning curve) – Jake T. Nov 1 at 15:57

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.