JSON vs BSON

JSON, or JavaScript Object Notation, is a lightweight and easy-to-read format that is widely supported by many programming languages. It is also human-readable and easy to edit, making it a popular choice for storing configuration data, transmitting data over HTTP, and exchanging data between web services. BSON, or Binary JSON, is a binary-encoded serialization format that is designed to be more efficient than JSON when working with large amounts of data. It supports more data types than JSON, including binary data, dates, and regular expressions, and can be up to 20-30% smaller in size than JSON. ...

September 16, 2024 · 2 min

MongoDB Master Slave Setup

Resource https://www.mongodb.com/docs/v2.4/core/master-slave/ IMPORTANT If stuck, first check netstat -tulnp and mongod -f config.conf to see if it is running or not. Make sure both are on same VPC with security groups configured. Use mongod -f config_file.conf to start with forked processes to run them. Here is SECONDARY node config file slave.conf storage: dbPath: /usr/local/var/mongodb/slave net: bindIp: 0.0.0.0 port: 27017 security: authorization: enabled keyFile: /usr/local/var/mongodb/pki/replicaset-keyfile systemLog: destination: file path: /usr/local/var/log/mongodb/slave/mongod.log logAppend: true processManagement: fork: true replication: replSetName: master-slave BindIp means it is listening to IP addresses mentioned. Here 0.0.0.0 means all of them, 127.0.0.1 is same as localhost only. It must listen at 0.0.0.0 to listen to all connections as slave. ...

September 14, 2024 · 3 min

MongoDB vs DocumentDB

MongoDB is also known as DocumentDB or NoSQL database. The reason it is called documentDB is it stores and retrieves data in the form of semi-structured or unstructured documents DocumentDB DocumentDB is AWS offering for NoSQL database which stores data in semi-structured data as documents than traditional relational data with fixed schema. It provides high scalability, high availability and security and works well for applications that require LOW latency and HIGH throughput for read/write operations. ...

September 13, 2024 · 6 min

Kubernetes Design Patterns

Multi-container design patterns Sidecar pattern An extra container in your pod to enhance or extend the functionality of the main container. Ambassador pattern A container that proxy the network connection to the main container. Adapter pattern A container that transform output of the main container. Reference - https://kubernetes.io/blog/2015/06/the-distributed-system-toolkit-patterns/ The idea for a sidecar container is to add some functionality not present in the main container. Rather than bloating code, which may not be necessary in other deployments, adding a container to handle a function such as logging solves the issue, while remaining decoupled and scalable. Prometheus monitoring and Fluentd logging leverage sidecar containers to collect data. ...

September 13, 2024 · 2 min

Deployments and Replicasets

Both Deployments and ReplicaSets are designed to manage stateless applications in Kubernetes. This means that they are not responsible for managing any application state or data storage. Instead, they manage the deployment and scaling of stateless pods that run the application code. In a stateless application, each pod is independent and interchangeable, and can be scaled up or down as needed. The application state is typically stored in a separate data store, such as a database, that is managed independently of the pods. ...

August 25, 2024 · 2 min

MongoDB ReplicaSet Setup Explained

For rstarting up a 3 node cluster with 1 master and 2 slaves follow this https://medium.com/swlh/mongodb-creating-a-3-node-replica-set-cluster-7ca94849b139 First we need a keyfile and appropriate permissions. If the mongod processes were actually running on different machines, then each machine will have a copy of this keyfile. Use OpenSSL to create keyfile - sudo mkdir -p /usr/local/var/mongodb/pki/ openssl rand -base64 741 > /usr/local/var/mongodb/pki/replicaset-keyfile chmod 400 /usr/local/var/mongodb/pki/replicaset-keyfile Create Mongod config files to start mongod processes. Here we will fork the processes to run multiple mongo. ...

July 30, 2024 · 2 min

MongoDB StatefulSet Setup

Creating a MongoDB Replica Set with authentication using StatefulSets involves several steps. Below is a manifest example for deploying a MongoDB Replica Set with authentication using StatefulSets in Kubernetes. This assumes you have a Kubernetes cluster set up and kubectl configured. Create a Secret for MongoDB Authentication: Create a Kubernetes Secret to store the MongoDB admin credentials. You can encode the username and password using echo -n 'yourpassword' | base64: ...

July 11, 2024 · 2 min

MongoDB notes

WiredTiger WiredTiger is a high-performance, open-source storage engine used by MongoDB to store and manage data. WiredTiger is designed to support high concurrency and high throughput workloads while maintaining low latency and high reliability. It is optimized for modern hardware architectures, including solid-state drives (SSDs), multi-core processors, and large memory configurations. Key features of WiredTiger: Document-level concurrency control: Allows multiple operations on the same document to be processed concurrently, improving performance and reducing lock contention. ...

July 8, 2024 · 6 min