Bringing Exoscale Managed Databases to the Voting App as an Acorn Service

Aug 14, 2023 by Luc Juggery
Bringing Exoscale Managed Databases to the Voting App as an Acorn Service

The Service feature introduced in Acorn 0.7.0 allows developers to easily provision cloud components such as databases or message queues so applications can utilize them. In previous articles we illustrated Acorn Services with MongoDB Atlas and NGS / NATS.

Also, as we used the Voting App as a sample application in this series of Acorn dedicated articles we will go one step further in the current article and show how Acorn Services can bring Exoscale managed databases to the Voting App.

About the Voting Application

As a reminder the Voting App is a microservices oriented application coming from Docker (and now living unofficially in The overall architecture of the application is the following one:


It basically exposes 2 web front ends allowing a user to vote between 2 items and then to see the results of the votes. This application replies on 2 databases:

  • redis is used to save each new vote
  • postgres gathers all the votes done since the launch of the application

When launched with the default options, both databases are deployed in containers alongside the other microservices. In the next part we will see how, using Acorn Service, this application can use hosted databases instead.

Acorn Service for Exoscale managed databases

Exoscale, a well known european cloud provider has a DB-as-a-Service offering which is powered by Aiven, one of the leading European companies for managing open source data infrastructure in the cloud. Among the technologies offered we can find redis, postgres, mysql and a couple of others.

Following the same structure of code we used for the MongoDB Atlas and NGS / NATS Services we created an Acorn Service allowing us to provision an Exoscale managed database, this new Service is available as an image in the Docker Hub


Note: this Service is currently for testing purposes only and will be enhanced soon.

The Service is available and ready to be consumed, but Before we can use it in the Voting App we need to make a couple of little changes to the application.

Changes done to the Voting Application

When the Exoscale DBaaS Acorn Service is triggered, it returns the following information regarding the database created:

  • host
  • port
  • username
  • password
  • additional options

For the Voting App to use the database we create a connection string out of the above information and provide this connection string to the calling microservices. Thus the Voting Application needed to be modified a bit to ensure:

  • the vote microservice can connect to a Redis database when the redis connection string is provided in an environment variable
  • the result microservice can connect to a Postgres database when the postgres connection string is provided in an environment variable
  • the worker microservice can connect to both Redis and Postgres databases when connection strings are provided in environment variables

Next we needed to change the application’s Acornfile adding the Service definitions and a couple of arguments. These new args can be used at launch time to specify the Voting App should use hosted databases instead of the local ones. The new version of the Acornfile is available here.

Once those changes were done, the Voting App was packaged in an Acorn image and pushed to the Docker Hub.

Capture d’écran 2023-06-28 à 16.01.48.png

With those changes in place the Voting App can now be run using local databases or with hosted databases. In the following parts we will test the 2 configurations.

Running the Voting App with local databases

First we run the latest version of the application (at time of writing) without any arguments as follows:


After a few tens of seconds we can see the application is up and running, it returns http endpoints as follows:


Using the http endpoints we can access the application, vote for our favorite pet and see the result.



The application is this running fine using local databases (the changes didn’t break anything 🙂 ).

We can now delete the application.


Running the Voting App with hosted databases

First we create a secret containing our Exoscale’s api keys, this step is required as the Acorn Service needs to connect to Exoscale in order to create hosted databases.


Next we run the Voting App providing both –hosted-redis –hosted-postgres and –hosted-redis –hosted-postgres flags:


After a few tens of seconds the Exoscale console shows both redis and postgres databases were created


Listing all the objects we can see there are no redis nor db containers, this indicates the application now relies on the external databases.


Using the http endpoints we can verify the application is running fine in this configuration too.



We can now remove the application


Key takeaways

This simple example shows how we can use the Acorn Service feature to bring Exoscale managed databases to the Voting App. The code used to create this Service is available on GitHub.

Want to know more about Acorn ? Feel free to follow this introductory workshop locally at your own pace (as always, all kinds of feedback are welcome).

Luc Juggery is a software engineer with 18+ years of experience and co-founder of 2 startups located in Sophia-Antipolis, southern France. You can chat with him on Twitter, read more of his work on Medium, find his tutorials on YouTube, or take one of his Docker or Kubernetes training courses on Udemy.