Will using replica set increase my read/write performance?

iam running a 3 node replicaset on a 4core 8gb ram(3Instances). Previously i was using 4core8gbram standaloneMongodb setup.

i have enabled read on secondaryNodes. So writes will be happening on primaryNode.
Will this increase my performance in any way?

Hi @Divine_Cutler you might get some benefits with increased read performance as you could spread your reads out to more machines. Note that depending on settings, you could get stale reads if the write hasn’t hit the secondary that you’re reading from. Note that read preference secondary means that secondaries will serve the reads. Should you have a primary-secondary-arbiter replica set and one of the data bearing nodes is down, then you won’t serve reads. In that type of scenario you might want to make that secondaryPreferred to be safe.

As for writes, you might get a little bit of increased performance, but probably not that much. You can scale your writes out by sharding. This will give you more primary nodes to write to, but if not done right, you could actually get less performance on writes.

Do you have a performance problem currently that needs to be taken care of now, or is this for general knowledge? The best way to figure out the set up for your environment is to set up test machines with actual data and send typical loads at them to see how they handle that load.

1 Like

@Doug_Duncan this is a problem that needs to be takencare of. could you share any available monitoring tools to check the performance of mongodb replicaset?

@Divine_Cutler MongoDB has a monitoring section in their documentation that can provide ideas for how you can monitor your instances.

One thing that they don’t mention however is the use of prometheus/grafana. I am a fan of these tools and even use them to monitor/visualize metrics from my computers at home.

Prometheus is a systems monitoring/alerting toolkit and you can find exporters for various needs. Prometheus just stores the data, and you need exporters for what you want to monitor. There are a couple of third-party (read non-official) exporters for MongoDB that I know of:

Grafana is a visualization and alerting tool that can be used with different data stores (Prometheus is one several available). If you go this route you will have to set each of the pieces up and learn the query language to build out your dashboards to get the most out of it, although you can find pre-built dashboards to get you started.

Prometheus/Grafana is not a toolset for everyone (which is why I mentioned the monitoring section of the docs above), but provides you the ability to build out the dashboards to help you visualize your system in the way that helps you out the best. If you don’t have the time to invest learning the tools, look at what’s prebuilt to see if they meet your needs.

3 Likes

Hello @Divine_Cutler

there is one more to add. This is the TICK stack (Telegraf, InfuxDB, Chronograf, Kapacitor). I did some work with Prometheus/Grafana (thanks @Doug_Duncan, love to use this ) and lately was asked to use the TICK stack. Both focus on the same subject, the cool thing with the TICK stack is that these are Go binaries which have no dependencies. What does that mean?
You start with the InfluxDB get it here just follow the brief documentation. For a test you can start with the default settings. Just run the DB with the default settings. Just add where your MongoDB is running.

Then get Telegraf, download the binary - it is just on executable, do not search for plugins, it is all in the binary! Then read the plugin documentation for mongodb. Go to the github page, copy the defaults and past it in the telegraf.conf file.

Start the telegraf, this will collect the data and write it to the InfluxDB. Now you want to get the visual part. Download Chronograf quick check the docs, but if you stay with the defaults, there is almost nothing to do. Again it is only one binary. Run it. Move to http://localhost:8888 and you can start monitoring.

When you once have passed the above steps (yes one time getting familiar with it is not in the binaries … ) then it will take you less then 30 min to set up the full TICK stack.

Happy Monitoring :slight_smile:
Michael

2 Likes

thank you @michael_hoeller i will take a look at it and update you

@Divine_Cutler working through this introduction to the TICK stack helped me out when I pulled it down to play with earlier today. The document is geared towards Mac users, but it should be easy enough to convert to the OS of your choice.

It did take me some playing around to get the mongodb input filter added and how to query the system to return results. I didn’t find much in the way of documentation, although I didn’t try all that hard. It’s more fun for me to play around to figure out how things work. :wink: While it’s easier to use than Prometheus/Grafana, I don’t think you have as many controls for building out dashboards. Of course I’ve used Prometheus/Grafana for years now and the TICK stack for a couple hours.

Hello @Doug_Duncan and @Divine_Cutler
Doug, thanks for the intro link. In step 2 they configure the telegraf via

telegraf --input-filter cpu:mem:system --output-filter influxdb config > /usr/local/etc/telegraf.conf

to simplify for the start and later use (since you may want to play with the already shipped config I’d suggest to take the default telegarf.conf as is, comment or uncomment as needed and run it like this

telegraf.exe --config telegraf.conf
(you may want to add a path if needed for the on or the other)

Cheers
Michael

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.