High Availability on Fargate
High availability ensures that your Appsmith instance remains accessible without interruption, even during system disruptions. This page outlines the steps required to set up high availability for your Appsmith installation on AWS ECS with Fargate.
Prerequisites
Before setting up high availability for Appsmith, ensure you have completed the following:
-
You need to have Appsmith Commercial Edition installed on AWS ECS using Fargate. If not already installed, refer to the AWS ECS on Fargate installation guide. This guide assumes you are working with an existing installation.
-
Ensure you have at least 2 GB of free storage available to perform backups and handle update tasks without interruptions.
-
You need an active Amazon Web Services (AWS) account with permissions to access and manage Elastic Container Service (ECS), Elastic File System (EFS), Relational Database Service (RDS), and ElastiCache. If you do not have an account, follow the AWS account creation guide.
-
Appsmith requires AWS EFS to provide persistent storage of application data. If your current setup uses a local volume or bind mount, upgrade to EFS before proceeding. See the Upgrade to AWS EFS guide for details.
-
Create a backup of your existing Appsmith instance to safeguard your data before proceeding. For detailed instructions, see How to back up your Appsmith instance.
-
Ensure you can run
supervisorctl
commands to manage Keycloak data backup and recovery.
Set up external databases
High availability for Appsmith requires configuring external databases for MongoDB, Redis, and PostgreSQL. Each of these databases needs to be set up correctly to ensure a robust, scalable environment.
Configure MongoDB
Appsmith requires MongoDB to store application data. To use an external MongoDB instance with Appsmith, follow the steps below to back up your data, configure the new MongoDB instance, and restore your Appsmith data if needed.
-
Take a backup of your existing MongoDB instance before proceeding. For more information, see How to take back up of MongoDB data guide.
-
If you don't already have a MongoDB instance, create a new one. You can either use an existing instance or set up a new one through your infrastructure or a cloud provider like MongoDB Atlas.
-
Log in to your MongoDB instance as an admin user. Then, run the following command to initiate the replica set configuration:
rs.initiate()
-
Assign or verify that the MongoDB user account Appsmith uses has
readWrite
andclusterMonitor
roles assigned. -
Restore your Appsmith backup you took earlier to the new MongoDB instance. For more information, see the Restore database guide.
-
Once your MongoDB setup is complete, note down the connection string as you’ll need it in the Configure High Availability section.
Configure Redis
Appsmith relies on Redis for caching and session storage. To configure Redis for high availability, follow these steps to create and set up your Redis instance.
-
If you don’t already have a Redis instance, create one using AWS ElastiCache. You can either create a new Redis cluster or use an existing one.
-
Log in to the AWS Management Console, search for ElastiCache, and select ElastiCache from the services list.
-
Click on Create Redis cache under the ElastiCache dashboard.
-
Choose the Serverless - new option for an auto-scaling Redis instance, or select Design your own cache to manually configure the cluster size and node types.
-
For a simple setup, select Easy create, which will configure the cluster using the best practice configurations.
-
Name: Provide a unique name for your cluster, for example,
test-redis
. -
Choose Node Type: Configure the Redis node type as follows:
- Production:
cache.r7g.large
(26.32 GiB memory, up to 12.5 Gigabit network performance). - Dev/Test:
cache.r7g.large
(13.07 GiB memory, up to 12.5 Gigabit network performance). - Demo:
cache.t4g.micro
(0.5 GiB memory, up to 5 Gigabit network performance).
- Production:
-
Review the settings, and once satisfied, click Create to launch the Redis instance.
-
Once the Redis cluster is created, copy and securely store the endpoint and connection details. You'll need these when configuring high availability in the next steps.
Configure PostgreSQL
Appsmith uses a PostgreSQL database to store its data. Keycloak data is used for Single Sign-On (SSO) configured using SAML and high availability. Follow the steps below to configure PostgreSQL:
Create PostgreSQL RDS instance
Follow these steps to create a PostgreSQL RDS instance on Amazon cloud:
- Go to the RDS section in the AWS Management Console and click Create database.
- Configure the database:
- Database creation method: Standard create
- Engine options: PostgreSQL
- Engine version: PostgreSQL 12.11-R1 or above
- Templates: Free tier
- DB instance identifier: For example,
appsmith-keycloak
- Credentials: Set username (
postgres
by default) and a strong password.
- Click Create database to create the database.
- If your Appsmith instance has an existing user base and you wish to migrate their data, follow the instructions in Migrate Keycloak Data on Fargate guide.
- Note the endpoint URL from the Connectivity & security tab, as you'll need this for the Keycloak setup.
Configure high availability
To ensure Appsmith is highly available, configure it to use multiple instances, redundancy, and external databases.
Update task definition
-
Go to the Amazon ECS console and select Task Definitions.
-
Select your Appsmith task definition and click Create new revision.
-
Add the following environment variables under Container-1. Use the values obtained during the Set up external databases section.
APPSMITH_DB_URL=<MongoDB connection string>
: Use the connection string for your MongoDB database, configured during its setup.APPSMITH_REDIS_URL=<Redis connection string>
: Use the Redis connection string or endpoint provided after setting up your Redis instance on AWS ElastiCache.APPSMITH_KEYCLOAK_DB_URL=<PostgreSQL endpoint>
: This should be the endpoint of the PostgreSQL database you set up for Keycloak.APPSMITH_KEYCLOAK_DB_DRIVER=postgresql
: Set the driver topostgresql
as Keycloak uses PostgreSQL for its database.APPSMITH_KEYCLOAK_DB_USERNAME=<PostgreSQL username>
: Enter the username you configured during the PostgreSQL setup.APPSMITH_KEYCLOAK_DB_PASSWORD=<PostgreSQL password>
: Use the password you created for thepostgres
user.
-
Save the updated task definition.
Update ECS service
To deploy your changes and ensure high availability, follow these steps:
- Go to the Amazon ECS console and select your ECS Cluster.
- Navigate to the Services tab and select your Appsmith service.
- Click Update, check Force new deployment, and select the latest task definition revision.
- Update the Desired tasks to
2
for redundancy. - Save the changes to initiate a new deployment.
- Verify the service’s Last status is Running.
Verify high availability
Once the deployment is complete, test the high availability setup by performing the following checks:
- Simulate a failover by terminating one task in your ECS service.
- Verify if the remaining task continues handling traffic seamlessly without any downtime.
- Ensure that no data is lost and that the system is highly available during the failover process.
Troubleshooting
If you encounter issues, follow these steps:
- Check the logs in the ECS console for detailed error messages that may indicate the root cause. For more information, see Get Container Logs guide.
- To roll back to a previous version of the Appsmith instance, follow the Restore instance guide.
If you continue facing issues, contact support using the chat widget available in the bottom-right corner of this page.
See also
- Restore Appsmith instance: Follow this guide to restore your Appsmith instance from a backup, ensuring minimal downtime and data loss.
- SAML Single Sign-On: Learn how to configure SAML-based Single Sign-On (SSO) for secure authentication in your Appsmith instance.