Giter Club home page Giter Club logo

mongo-oplog-populator's Introduction

Mongo-oplog-populator

MongoDB oplog populator (alias mongopop) allows you to simulate traffic (insert, update and delete) in MongoDB. This repo is a companion repo for https://github.com/one2nc/mongo-oplog-to-sql. If you want to test your oplog2sql binary on large data, you should use mongopop.

mongo-oplog-flow

How it works?

When you execute the mongopop command, the process dynamically generates databases and collections based on the configurations specified in the .env file. This dynamic creation of databases and collections is controlled by the values of MAX_DB and MAX_COLLECTION in the .env file.

mongopop supports two modes: bulk mode and stream mode.

  1. Bulk mode: Perform fixed number of operations and terminate the program.
  2. Stream mode: Perform fixed number of operations per second for indefinite time. The program stops only when you give a stop signal (ctrl+c)

The number of operations you specify via CLI are divided into insert, update and delete operations in following proportion.

  • 85% Insert
  • 10% updates
  • 5% deletes

The mongopop utility carries out insert, update, and delete operations in a randomized manner. For instance, if you designate 100 operations, the distribution will be as follows: 85 of them will be inserts, 10 will be updates, and 5 will be delete operations. These operations are performed individually for each database collection combination. To illustrate, consider the scenario where you execute $ ./mongopop 100 with MAX_DB=2 and MAX_COLLECTION=2. In this case, all 100 operations will be performed on database1.collection1, database1.collection2, database2.collection1, and database2.collection2.

Setup

  1. Setup MongoDB: Start a MongoDB replica server with 3 MongoDB instances (1 primary and 2 secondaries)

    make setup

  2. Build the application: Builds a binary of mongo-oplog-populator, i.e. mongopop

    make build

  3. Create a .env file. You can refer .env.example file

  4. Run ./mongopop 10 for bulk operations and ./mongopop -s 10 for stream operations

    • ./mongopop is the binary file
    • -s is the flag for stream operation
    • 10 is the total number of operations to be performed in case of bulk insert and per second in case of stream insert
  5. To connect to MongoDB cluster make connect

  6. To check oplogs in MongoDB execute the following commands:

    • Change the database to local in MongoDB shell (use local) since all the oplogs are located in a oplog.rs collection in local database.
    • To see the oplogs generated:
      • db.oplog.rs.find({}) to see all oplogs
      • db.oplog.rs.find({op:"i"}) to see the insertions
      • db.oplog.rs.find({op:"u"}) to see the updates
      • db.oplog.rs.find({op:"d"}) to see the deletions
  7. Tear down MongoDB make setup-down

NOTE: If you want to simulate the load on the MongoDB by inserting more records, run multiple instances of mongopop.

License

This project is licensed under the MIT License

mongo-oplog-populator's People

Contributors

chinmaysomani07 avatar aanamshaikh avatar kalpeshdeo avatar aastha97 avatar chinmay185 avatar

Watchers

Jaideep Khandelwal avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.