Search code examples
androidiosmysqlbackground-process

Can I use a background task to process data from a server every 1 sec?


I'd like to dedicate 1% of the processing power of each device my app is installed into for the greater good. A background task should start running once you open the app and continue when you exit the app for multitasking purposes.

Background Task

  1. Download small amounts of data (<1KB) every 1 sec.
  2. Process them using 1% of the processing power of the device.
  3. Rarely, upload small amounts of data (<1KB).

In the example below I'm using MySQL but it will certainly not be done with MySQL.

Also, note that the actual numbers will be largely optimized in the end and that's where the 1% figure comes from.

Obviously, I can't specifically tell the device to use 1% of its processing power.

Open App

Connect to a MySQL server.

Download Data

It should read a cell in the MySQL database with data less than 1KB in size every 1 sec.

Processing

Requires reading a relatively large amount of data (1MB) from the device every 1 sec.

Upload Data

Rarely, it should write a cell in the MySQL database with data less than 1KB in size.

Kill App

Disconnect from the database.

I figured, where mobile devices excel is their memory speed and internet connectivity.

Will repeatedly reading from a MySQL database and the disk of the device hog it's performance and battery life?

Most importantly, does iOS and Android allow for complex background tasks of this kind?


Solution

  • Android allows for these complex background tasks but iOS does not.