Background worker
  • 21 Jul 2020
  • 1 Minute To Read
  • Contributors
  • Print
  • Share
  • Dark
    Light

Background worker

  • Print
  • Share
  • Dark
    Light

A background worker helps to offload long-running function calls to the background so that your product's interface won't freeze.

Usually this is a service that listens to the queue for tasks from an API and other sources.

Deploying a background worker is pretty similar to deploying an API. You can launch a background worker as a private service as long as the queue is on the same private network.

Use these instructions to run the API using your programming language:

Queue

If you don't have a queue yet, you can deploy one on Hostman.

Launch Kafka or RabbitMQ to receive tasks from the API.

Database

iconfinder_017_064_cloud_data_base_database_rack_server_backup_2328996.png

Your data must be stored in a database. Hostman provides you with out-of-the-box databases: PostgreSQL, MySQL and MongoDB. When you deploy them using Hostman, you see the database requisites right in your Dashboard.

Other supported databases

We have other databases in our backlog. If you would like us to implement support for your database, please email us.

You can also install any other database using a Docker container.

File storage

iconfinder_folder_286705.png

If you are not planning to scale your API, you can use local storage to store your files. Use persistent storage for files that will not be deleted between deploys.

When you need to scale your service, it's important to store files outside the node. There are many different options.

We recommend using GridFS. GridFS is the MongoDB specification for storing and retrieving large files such as images, audio files, video files, etc. It is a storage file system, but the data is stored in MongoDB collections.

To use GridFS you need to deploy MongoDB and install the GridFS driver for your programming language.

Was This Article Helpful?