Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Performance: Managing threads in Couchbase 2.x

DZone's Guide to

Performance: Managing threads in Couchbase 2.x

· Performance Zone
Free Resource

Discover 50 of the latest mobile performance statistics with the Ultimate Guide to Digital Experience Monitoring, brought to you in partnership with Catchpoint.

Originally written by Kirk Kirkconnell

In this blog post you will get an overview of two related performance optimizations that you can do for Couchbase 2.5.1 and below. This is not for 3.x for reasons you can read at the bottom of this post. The two changes directly effect performance of reading and writing in Couchbase. Also know that you must have a properly sized cluster before you start messing with these settings. If you do not, you may cause more problems for the cluster than you solve. If you need more information about sizing your cluster, please see Perry's execellent blog series on the topic.

Adding More Reader/Writer Threads Per Bucket

The first is changing the number of threads available on a per bucket basis. This should only be done if you have enough server/instance resources for this. If you are runing only 4 cores on your Couchbase nodes, this is probably not the performance enhancement for you. This setting will allow Couchbase to use more reader/writer threads and thus push more operations. So in the configuration of each bucket you will see a part of that screen that looks like this:

Note: Changing this value REQUIRES a restart of the bucket. This is one of the very few off-line operations in CB. So do not change this on your production cluster without a planned maintenance window and planned down time!! Couchbase will do that bucket restart for you once you change the value and save it, but plan for the down time.

For more information on this see the official documentation.

Optimizing More for Mixed Usage or Write heavy workloads

The second optimization links in with the first one. It has to do with optimizing Couchbase for either reading, writing or both. By default, Couchbase is optimized for reading thread wise and for many use cases, that works great. If you have mixed or a write heavy use case, you want to optimize Couchbase for that. You change these values with a REST API call like below with wget:

wget -O- --user=<admin user> --password=<password> --post-data='ns_bucket:update_bucket_props("<bucket name>", [{extra_config_string, "workload_optimization=mix"}]).' http://localhost:8091/diag/eval

The third option is to weight the threads towards writers:

wget -O- --user=<admin user> --password=<password> --post-data='ns_bucket:update_bucket_props("<bucket name>", [{extra_config_string, "workload_optimization=write"}]).' http://localhost:8091/diag/eval

If you want to set this back to the default, you'd do:

wget -O- --user=<admin user> --password=<password> --post-data='ns_bucket:update_bucket_props("<bucket name>", [{extra_config_string, "workload_optimization=read"}]).' http://localhost:8091/diag/eval

Is this still necessary for Couchbase 3.0?

No. These optimizations are no longer necessary in 3.x because of the introduction of a feature called the Global Thread Pool. With that feature, Couchbase now manages the the number of threads and the balance of threads dynamically for you and with intelligence as to your workload.


Is your APM strategy broken? This ebook explores the latest in Gartner research to help you learn how to close the end-user experience gap in APM, brought to you in partnership with Catchpoint.

Topics:

Published at DZone with permission of Don Pinto, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}