Skip to content

CouchbaseContainer high CPU usage when more than one bucket is created #2802

@aaronjwhiteside

Description

@aaronjwhiteside

We are looking to replace our custom couchbase docker image (handles node setup, bucket creation, user provisioning, etc..) that we use for our internal testing with the stock image and CouchbaseContainer from this project.

However we've noticed a blocker for us, when creating more than one bucket, CPU usage in the container is consistenty high, on my setup (MBP 2018, 32GB with 6 cores) two buckets cause memcached to use 75% cpu and three buckets casue it to use 100+% cpu..

This does not happen with our custom container, which is using the exact same base image + custom startup script to configure everything via the CLI.

I have tried to dig though how CouchbaseContainer sets everything up via REST APIs but sometimes it's not obvious the relationship to the CLI tools..

Something in the configuration of Couchbase is obviously different and the cuprit here..

With three buckets, if you try and create some indices, you'll also get weird errors about the indexer running out of memory.. even though in our env there are about 10 small documents in each bucket.

It should be noted that these indices work fine on our custom image and we have the indexer memory set to 256mb vs the default here of 512mb..

You might say that this is an issue with Couchbase and not the TestContainers wrapper, but I think if out of the box creating more than a single bucket causes this issue, then something about how the TestContainers wrapper does it needs to be fixed..

[user:info,2020-05-28T02:59:42.942Z,ns_1@192.168.48.3:<0.27074.1>:menelaus_web_alerts_srv:global_alert:119]Warning: approaching max index RAM. Indexer RAM on node "192.168.48.3" is 100%, which is at or above the threshold of 75%.
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                           
  348 couchba+  20   0 2534520 123848  12540 S 115.7  1.2  34:41.65 memcached                                                                                         
  394 couchba+  20   0 1830936 229840  21812 S  27.3  2.3   7:30.09 indexer                                                                                           
  167 couchba+  20   0 4525784 465760   6940 S  27.0  4.6  11:55.94 beam.smp 

Code to reproduce:

        final CouchbaseContainer couchbase = new CouchbaseContainer()
                .withReuse(true)
                .withNetwork(Network.SHARED)
                .withBucket(new BucketDefinition("test1")
                        .withPrimaryIndex(false))
                .withBucket(new BucketDefinition("test2")
                        .withPrimaryIndex(false))
                .withBucket(new BucketDefinition("test3")
                        .withPrimaryIndex(false));
        couchbase.getNetworkAliases().clear();
        couchbase.start();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions