testcontainers-java: CouchbaseContainer high CPU usage when more than one bucket is created

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();

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

memached

Best. Typo. Ever. 😂 😂 😂

@aaronjwhiteside I’ve been digging into this further and for the sake of other people seeing this too: check out this thread on docker for mac and postgres: https://twitter.com/felixge/status/1221512507690496001

Looks like there is an issue with docker for mac and time drift… the suggested fix: https://twitter.com/felixge/status/1221512685008883712 restart docker for mac… I did that and indeed cpu is at 10% and not 100 … looks like we call clock_gettime more in 6.5 than 6.0 because of the sync durability timers

@daschl FYI, opened CB support request #34433

Note that with your code I can also see that the creation of the 3 buckets worked, but memcached cpu is at 100% without any actual ops going on. One other difference is that you created with 0 replicas - I’ll see if tweaking the default settings causes a change in behavior on the server side