Try Live Demo

A database is generally an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage.

database line style icon free vector

The design of databases spans formal techniques and practical considerations, including data modeling, efficient data representation, and storage, query languages, security and privacy of sensitive data, and distributed computing issues, including supporting concurrent access and fault tolerance.

Ant Media server supports several databases such as MongoDB, MongoDB Atlas (mongodb+srv), Redis, and MapDB.

MongoDB

MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. A record in MongoDB is a document, which is a data structure composed of key-value pairs similar to the structure of JSON objects.

MongoDB Logo

MongoDB is one of the popular databases for running the Ant Media server in Ant Media Cluster Setup and is deployed by most users. It can be accessed via the command line and tools like Studio 3T and others.

How to use MongoDB with Ant Media server?

There are two ways to change the database and server mode in Ant Media Server.

Using the change_server_mode.sh

change_server_mode.sh is located under the installation directory which is /usr/local/antmedia and the method is recommended when you’re running Ant Media Server as a service

Type the following command to use MongoDB in cluster mode

sudo ./change_server_mode.sh cluster  [MONGODB_SERVER_IP] 

Note: If you set username and password authentication on MongoDB, you should run change_server_mode.sh as follows:

sudo ./change_server_mode.sh cluster [MONGODB_SERVER_IP] [MONGODB_USERNAME] [MONGODB_PASSWORD]

MongoDB can be used in standalone mode with the below command

sudo ./change_server_mode.sh standalone  [MONGODB_SERVER_IP] 

Using the start.sh script

This script is also located in the installation directory and the method is recommended when you’re running Ant Media Server in Kubernetes or a container. Starting the Ant Media Server with MongoDB in standalone mode using start.sh script

sudo ./start.sh -m standalone -h [MONGODB_SERVER_IP] [MONGODB_USERNAME] [MONGODB_PASSWORD]

Starting the Ant Media Server with MongoDB in cluster mode

sudo ./start.sh -m cluster -h [MONGODB_SERVER_IP] [MONGODB_USERNAME] [MONGODB_PASSWORD]

MongoDB Atlas (mongodb+srv)

MongoDB Atlas is a multi-cloud database service. It simplifies deploying and managing the databases while offering the versatility to build resilient and performant global applications on the cloud providers of your choice like Amazon web services and Microsoft Azure, etc.

How to use mongodb+srv in the Ant Media server?

Once you have launched the Atlas database cluster on the cloud platform of your choice, it can be used with Ant Media Server with the mongodb+srv URI.

Using the change_server_mode.sh

The following command can be used for mongodb+srv in cluster mode

sudo ./change_server_mode.sh cluster mongodb+srv://[username]:[password]@[url]

To use mongodb+srv in standalone mode

sudo ./change_server_mode.sh standalone mongodb+srv://[username]:[password]@[url]

Using the start.sh script

To use mongodb+srv in cluster mode with the start.sh script

sudo ./start.sh -m cluster -h mongodb+srv://[username]:[password]@[url]

To use mongodb+srv in standalone mode

sudo ./start.sh -m standalone -h mongodb+srv://[username]:[password]@[url]

Redis

Redis is an open-source, in-memory data store used by millions of developers as a database, cache, streaming engine, and message broker.
Also, Redis delivers sub-millisecond response times, enabling millions of requests per second for real-time applications.

Redis Logo.wine

There are a good number of managed services for Redis in cloud providers e.g., AWS has MemoryDB for Redis and ElasticCache for Redis, Azure has Azure Cache for Redis, etc.

How to use Redis in Ant Media Server?

The support for Redis on Ant Media Server is introduced with AMS v2.5 along with many other advancements in conference solutions and Filter plugins, etc.

Using the change_server_mode.sh

The following command can be used for Redis in cluster mode

sudo ./change_server_mode.sh cluster redis://[username:password@]host:port]

To use Redis in standalone mode

sudo ./change_server_mode.sh standalone redis://[username:password@]host:port]

Using the start.sh script

To use Redis in cluster mode with the start.sh script

sudo ./start.sh -m cluster -h redis://[username:password@]host:port]

Using Redis in standalone mode with start.sh

sudo ./start.sh -m standalone -h redis://[username:password@]host:port]

Note:
-m
refers to the mode in which Ant Media Server is running (standalone/cluster)
-h refers to the host

MapDB

MapDB provides Java Maps, Sets, Lists, Queues, and other collections backed by off-heap or on-disk storage. It is a hybrid between a Java collection framework and an embedded database engine. It is free and open-source under an Apache license.

mapdb

Ant Media Server uses MapDB as the default database when running in standalone mode. It can be read and written on the server side directly from the related repository on Ant Media Server.

Kubernetes

Kubernetes, also known as K8s, is an open-source container orchestration system for automating deployment, scaling, and management of containerized applications and is widely used all over the world. Ant Media Server can be launched and scaled very efficiently with Kubernetes.

Kubernetes logo

In the Ant Media Server sample Kubernetes deployment file, the local MongoDB is used as the database by default.
This can be changed by passing your custom database parameters in the Kubernetes deployment file.
e.g., -h redis://[username:password@]host:port]

Don’t keep the queries stored…

We host Community Hours every first Thursday of each month at 3 pm (GMT +3), where you may ask your questions to AMS development or deployment.

Also, join our community and be a part of the Ant Colony. Visit https://github.com/orgs/ant-media/discussions/


Mohit Dubey

Mohit is your go-to Technical Support Engineer at Ant Media Server with the aim to make the streaming seamless and accessible, proficient in navigating cloud platforms. He likes to contribute towards product installation/deployment, testing, documentation, troubleshooting, and customer support, etc. Also, well-versed with AWS Streaming Wizard and the ins and outs of Ant Media Server.