MongoDB is our default storage option. We support the following versions:
- MongoDB 4.4.x (with mgo driver)
- MongoDB 4.4.x, 5.0.x, 6.0.x (with mongo-go driver).
Note: mongo-go driver is available from Tyk 5.0.2.
MongoDB 3.x to 4.2.x
mgo driver works with MongoDB 3.x to 4.2.x too, but we no longer test MongoDB versions prior to 4.4 since they are EOL
You can also use the following as a drop-in replacement for MongoDB:
Choose a MongoDB driver
From Tyk 5.0.2, we added an option to use the official MongoDB Go driver to connect to MongoDB.
We recommend using the mongo-go driver if you are using MongoDB 4.4.x+. For MongoDB versions prior to 4.4, please use the mgo driver.
With the mongo-go driver, we support the latest versions of MongoDB (5.0.x and v6.0.x) and also features such as the “+srv” connection string and SCRAM-SHA-256. For more details, visit the MongoDB doc:
You can configure which driver to use with the MongoDB driver option:
Split out your DB
This is a no-brainer, but keep Redis and MongoDB off the system running the Gateway, they both use lots of RAM, and with Redis and the Gateway constantly communicating you will be facing resource contention on the CPU for a marginal decrease in latency.
So in our setup, we recommend that Redis and MongoDB/PostgreSQL live on their own systems, separate from your Tyk Gateway. If you like, run them together on the same box, that’s up to you.
The network topology we like to use is:
- Two or more Tyk Gateway nodes (load balanced, each Gateway installed on separate machines).
- A separate MongoDB or PostgreSQL cluster
- A separate Redis server with fail-over or cluster
- One Tyk Dashboard node installed on a separate machine
- One Tyk Pump node installed on a separate machine that handles data transitions
Special notes for DocumentDB
Special notes for MongoDB Atlas
In order to integrate with MongoDB Atlas, make sure the IP firewall connections are whitelisted on the Atlas side, and then use the following Tyk Dashboard configurations to connect:
- TYK_DB_MONGOURL=mongodb://admin:[email protected]:27017,tykdb-shard-00-01.h42pp.mongodb.net:27017,tykdb-shard-00-02.h42pp.mongodb.net:27017/tyk_analytics?authSource=admin - TYK_DB_ENABLECLUSTER=false - TYK_DB_MONGOUSESSL=true
More information on these configuration variables here.