Instana

Instana

The community for performance and observability professionals to learn, to share ideas, and to connect with others.

 View Only

Self-Hosted Standard Edition Instana Datastore tuning examples - Part 2

By Oleg Samoylov posted 09/21/26 06:56 PM

  
Default deployment of Standard edition of Instana only has memory requests (best efforts), that allows all resources to be allocated to Instana components in order to see what is the natural resource consumption by Instana components and shape of the call/metrics flow. We recommend consider switching datastores to a "guaranteed" scheme of resource distribution when memory "requests" equal to the memory "limits". It serves for the better memory usage by datastores and enhanced pod handling by kubernetes.
When node is running out of resources kubernetes select pods to restart and first candidates for eviction are the best-efforts pods, which consume a lot. Databases can be very resource intense databases eviction triggers buffer overflows on Instana components making things even worse. To increase Instana stability and better resource planning we can shape Instana datastores for the load by tuning their resources.

We strongly recommend avoid setting CPU Limits for Instana datastores. The reason for that is we need to avoid CPU throttling during short CPU spikes. When it happens it crucially affects databases in general.

Instana Standard edition has balanced configurations of datastores and in most cases it is enough to attach separate SSD drives for each datastore in the beginning to avoid performance issues. Granting more resources to datastores might also help when disk performance is not a bottleneck. From another perspective of storage question the datastores won't use 100% or start to get very slow if they near 80%. It happens because when filesystem writes files it is using available free blocks, but datastores constantly consume and release storage, this way when disk approaches 80%, free space is mostly consist of many small blocks of unused storage. This causes operating system to perform more input/output operations than on empty drive. Performance of datastores significantly declines when there are less than 20% of free space. By default, datastores have watermarks of 85%, when storage consumption reaches the number they usually stop writing new data.
We recommend start tuning once resources usage approaches to 90% constantly or suddenly this sutuation potentially may lead to CPU throttling when we speak of CPU resource or in case of memory it is also a potential service unavailability as kubernetes will try to evict pods under the memory pressure on a node. Another trigger for tuning are gaps on diagrams or long response in the UI which are signs of competition for resources between components.

Elasticsearch


Best practice for Elasticsearch includes following considerations:
- Plan 1Gb of heap size per up to 20 shards (or 3k indices)
- Shard size should be between (10Gb ... 50Gb) smaller shard size increases overhead, larger size - reduces performance.

Elasticsearch tuning example in core manifest


There are 3 configuration items on Instana core manifest that creates a default templates for creating new indices. Use command kubectl edit core instana-core -n instana-core to adjust elasticsearch configs:
cat  << EOF > ~/.stanctl/values/instana-core/custom-values.yaml
datastoreConfigs:
  elasticsearchConfig:
    defaultIndexRoutingPartitionSize: 4
EOF

stanctl backend apply
where:
* defaultIndexRoutingPartitionSize - is the number of shards a custom routing value can go to. Defaults to 4 and can only be set at index creation time. This value must be less than the number of shards (Instana uses 5 shards by default).


Elasticsearch cluster tuning


We can change configuration for the Elasticsearch cluster. Let's set heap (by default elasticsearch will use 50% of available memory for heap) and pod memory requests and limits. For that we will create additional configuration file custom-values.yaml that will be merged together with default configuration file instana-values.yaml

1. Create file ~/.stanctl/values/instana-elasticsearch/custom-values.yaml and set the config adjustments (review the following example values):
cat  << EOF > ~/.stanctl/values/instana-elasticsearch/custom-values.yaml
nodeSets:
  - config:
      indices.breaker.fielddata.limit: 75%
      ingest.geoip.downloader.enabled: false
      node.roles:
        - master
        - ingest
        - data
      node.store.allow_mmap: false
      search.max_buckets: 300000
    containerName: elasticsearch
    count: 1
    env:
      - name: ES_JAVA_OPTS
        value: -Xms2000m -Xmx2000m
    name: default
    priorityClassName: system-cluster-critical
    resources:
      limits:
        memory: 5000Mi
      requests:
        cpu: 600m
        memory: 5000Mi
    storageClassName: local-path-data
    volume:
      resources:
        requests:
          storage: 1Gi
EOF

2. To apply changes execute the command once the file created:
stanctl datastores apply
The command will trigger applying manifests for all datastores. As soon as configuration for other datastores was not changed

3. Review changes:
kubectl describe es -n instana-elasticsearch | grep -iE 'Xms|memory'

Re-create Elasticsearch cluster from scratch

In cases when Elasticsearch cluster missed or corrupted its data, we might need to recreate it from scratch. The procedure is to delete current Elasticsearch cluster and trigger datastores creation. To delete current cluster:
kubectl delete es elasticsearch -n instana-elasticsearch

Ensure there are no PVCs left from current deployment:
kubectl delete pvc --all -n instana-elasticsearch

Create missing datastores:
stanctl up

Elasticsearch troubleshooting commands


Create Elasticsearch alias:
# Alias for K3s environment
ELASTICPASS=`kubectl -n instana-elasticsearch get secret elasticsearch-es-elastic-user --template='{{ index .data "elastic" | base64decode }}'`
alias es="kubectl -n instana-elasticsearch exec elasticsearch-es-default-0 -- curl -uelastic:$ELASTICPASS"

Useful commands to troubleshoot:
########################## Ensure current status ##########################
### cluster status
es -s -X GET "localhost:9200/_cluster/health?filter_path=status,*_shards&pretty"

### current nodes, cpu, heap, ram usage stats
es -s -X GET "localhost:9200/_cat/nodes?v=true&pretty"

### current jvm usage per node
es -s -X GET "localhost:9200/_cat/nodes?v=true&h=name,node*,heap*&pretty"

### disk allocation
es -s -X GET "localhost:9200/_cat/allocation?v&s=node&h=node*,shards,disk.percent,disk.indices,disk.used"

### list of indices
es -s -X GET "localhost:9200/_cat/indices?v=true&pretty"

### shards distribution
es -s -X GET "localhost:9200/_cat/shards?v=true&pretty"

### number of indexes/shards
es -s -X GET "localhost:9200/_cluster/stats?filter_path=indices.shards.total&pretty"

### list of indexes and current size of shards
es -s -X GET "localhost:9200/_cat/shards?v=true&h=index,prirep,shard,store&s=prirep,store&bytes=gb&pretty"

### list of nodes with heapize
es -s -X GET "localhost:9200/_nodes/stats?human&filter_path=nodes.*.name,nodes.*.indices.mappings.total_estimated_overhead*,nodes.*.jvm.mem.heap_max*&pretty"

### queue backlog
es -s -X GET "localhost:9200/_cat/thread_pool?v&s=t,n&h=id,type,name,node_name,active,queue,rejected,completed&pretty"

### check overhead stats
es -s -X GET "localhost:9200/_nodes/stats/breaker?pretty"

### rejected tasks
es -s -X GET "localhost:9200/_cat/thread_pool?v=true&h=id,name,active,rejected,completed&pretty"

### indices throttling
es -s -X GET "localhost:9200/_nodes/stats?human&filter_path=nodes.*.name,nodes.*.indices.indexing" | jq

### search totals per node
es -s -X GET "localhost:9200/_nodes/stats?human&filter_path=nodes.*.name,nodes.*.indices.name,nodes.*.indices.search" | jq

### searching for problematic index
es -s -X GET 'localhost:9200/_stats/indexing,search?level=shards&human&expand_wildcards=all' | jq

### templates
es -s -X GET "localhost:9200/_template?pretty"


########################## Shard allocation commands ##########################
### Explain node allocation
es -s -X GET "localhost:9200/_cluster/allocation/explain?pretty"


########################## Free up space ##########################
### Delete index 'onprem_tenant_unit_search_20244'
es -s -X DELETE "localhost:9200/onprem_tenant_unit_search_20244?pretty"


Cassandra


In Instana Standard edition Cassandra works as a single node, there is no need to scale it up horizontally. When two cassandra nodes work on the same node there is not much benefits on that scaling. Instead vertical scale can be used to increase performance when Cassandra is a bottleneck.

Cassandra cluster tuning


Let's see how can we change configuration for the cluster and increase heap and pod memory requests for Cassandra cluster. For that we can create additional configuration file custom-values.yaml that will be merged together with default configuration file instana-values.yaml before applying:

1. Create file ~/.stanctl/values/instana-cassandra/custom-values.yaml with the config adjustments:
cat  << EOF > ~/.stanctl/values/instana-cassandra/custom-values.yaml
jvmServerOptions:
  initialHeapSize: 1200M
  maxHeapSize: 1200M
resources:
  requests:
    memory: 2400Mi
size: "1"
EOF
2. To apply changes execute the command once the file created:
stanctl datastores apply
The command will trigger applying manifests for all datastores. As soon as configuration for other datastores was not changed

3. Review changes:
kubectl describe cassdc -n instana-cassandra | grep -iE 'heap|memory'

Re-create Cassandra cluster from scratch

Cassandra keeps short term metric history used for raw and 5s rollups, if you're ok to delete all metrics from cassandra, we can delete the cluster and recreate it from scratch:
## Delete Cassandra object, it will trigger pod termination and PVC deletion
kubectl delete cassdc cassandra -n instana-cassandra

## Normally all PVCs should be gone, but just in case, ensure there are no PVCs left:
kubectl delete pvc --all -n instana-cassandra

## Re-create missing datastores:
stanctl up

Commands to troubleshoot Cassandra cluster


Set aliases to work with Cassandra on k3s cluster:
CASSPASS=`kubectl -n instana-cassandra get secret cassandra-admin --template='{{ index .data "password" | base64decode }}'`
alias cass="kubectl -n instana-cassandra exec instana-cassandra-default-sts-0 -- nodetool --username instanaadmin --password $CASSPASS "
alias cs="kubectl -n instana-cassandra exec instana-cassandra-default-sts-0 -- cqlsh --username instanaadmin --password $CASSPASS -e"

To troubleshoot Cassandra cluster:
### status of cassandra cluster
cass status

### info of the cluster (heap and cache usage)
cass info

### cluster description
cass describecluster

### list kespaces
cs "select * from system_schema.keyspaces;"

### list tables in shared
cs "SELECT keyspace_name, table_name, compaction FROM system_schema.tables WHERE keyspace_name = 'shared';"

### list tables in onprem_tenant0_unit0
cs "SELECT keyspace_name, table_name, compaction FROM system_schema.tables WHERE keyspace_name = 'onprem_tenant0_unit0';"

### get table info
cs "SELECT * FROM system_schema.columns WHERE keyspace_name = 'onprem_tenant0_unit0' AND table_name = 'metrics5000';"

### get table info
cs "SELECT * FROM system_schema.columns WHERE keyspace_name = 'onprem_tenant0_unit0' AND table_name = 'raw_payloads_with_timestamp';"

### Cassandra tables size
### https://stackoverflow.com/questions/27011886/how-to-know-the-size-of-a-keyspace-and-column-family-in-cassandra
cass cfstats -H | awk -F ' *: *' '
BEGIN { print "Keyspace,Table,Live,Total" }
/^Keyspace : / { ks = $2 }
/\tTable:/ { t = $2 }
/\tSpace used .live/ { sp = $2 }
/\tSpace used .total/ { print ks "," t "," sp "," $2 }
' | column -s , -t


Postgres


Instana Standard Edition has one node of postgres datastore. It keeps custom configurations users do in Instana. High performance is not required of the database. In most cases you do not need to adjust it. Only just in case if too many customizations done we might grant it a little more resources.

Increase resources


Example with cpu and memory requests:

1. Create file ~/.stanctl/values/instana-postgres/custom-values.yaml
cat  << EOF > ~/.stanctl/values/instana-postgres/custom-values.yaml
resources:
  limits:
    memory: 2Gi
  requests:
    cpu: 450m
    memory: 2Gi
EOF

2. Apply changes:
stanctl datastores apply

3. Review changes:
kubectl describe cluster -n instana-postgres | grep -i memory

Postgres cluster troubleshooting commands


## Postgres status:
kubectl get cluster -n instana-postgres

## Postgres database sizes:
kubectl exec -it postgres-1 -n instana-postgres -- psql -c '\l+'

##Vacuum all tables in `butlerdb` database:
kubectl exec -it postgres-1 -n instana-postgres -- psql butlerdb -c "vacuum verbose;"



Clickhouse


Clickhouse is one of the most intensive datastore in Instana Standard Edition, it is always recommended to use a separate physical drive for the database. If the drive shared with other datastores, under load it might compete for disk IO operations with other datastores, to avoid performance issues on shared drive it might be required to increase memory resource.

Increasing memory for Clickhouse cluster


A file custom-values.yaml has the same structure of instana-values and will be merged together before applying. So,
1. Create file ~/.stanctl/values/instana-clickhouse/custom-values.yaml
cat  << EOF > ~/.stanctl/values/instana-clickhouse/custom-values.yaml
clickhouse:
  resources:
    limits:
      memory: 5000Mi
    requests:
      cpu: 2000m
      memory: 5000Mi
EOF

2. Apply changes:
stanctl datastores apply

3. Review changes:
kubectl describe chi -n instana-clickhouse | grep -i memory

There is no need for setting CPU limits and PVC sizes, because CPU by default is unlimited and in Standard edition datastores can utilize more space than granted via PVC config just need to ensure volume has enough free space.

Re-create Clickhouse cluster


In case of significant issues with clickhouse and if we're ok to lose calls and logs we can re-create the cluster. The procedure below explains the cluster deletion and re-creation from scratch:
## delete existing clickhouse cluster:
kubectl delete chi clickhouse -n instana-clickhouse

###delete existing clickhouse-keeper cluster:
kubectl delete chk clickhouse-keeper -n instana-clickhouse

###re-create missing datastores:
stanctl up

Troubleshooting clickhouse


Instana Standard edition uses only one shard of clickhouse cluster and no replica by default. In general there is no need to create more shards and replicas because in Instana Standard edition they will work on the same kubernetes nodes and it means not much of a benefits for sharding and replicating. Below are some examples of how we can use SQL commands against the Clickhouse cluster for troubleshooting purposes:
## Alias for K3s
alias chi="kubectl exec -n instana-clickhouse -c instana-clickhouse chi-clickhouse-local-0-0-0 -- clickhouse-local -q "
## show databases
chi "show databases;"

## used/free space per database:
chi "SELECT * FROM system.disks FORMAT vertical;"

## select number of detached parts
chi "select count() from system.detached_parts"

Kafka


Standard edition uses one node Kafka cluster. The same approach for changing resources for it as per other datastores.

Increasing memory for Kafka cluster


A file custom-values.yaml should have the same structure of instana-values and will be merged together before applying. So,
1. Create file ~/.stanctl/values/instana-kafka/custom-values.yaml
cat  << EOF > ~/.stanctl/values/instana-kafka/custom-values.yaml
resources:
  controller:
    limits:
      memory: 1Gi
    requests:
      cpu: 500m
      memory: 1Gi
  kafka:
    limits:
      memory: 2500Mi
    requests:
      cpu: 650m
      memory: 2500Mi
EOF

2. Apply changes:
stanctl datastores apply

3. Review changes:
kubectl describe knp -n instana-kafka


Recreate Kafka cluster


In case of issues with kafka and if we're ok to loose temporal data we can recreate the cluster. The procedure below explains the cluster deletion and re-creation from scratch:

1. delete existing kafka cluster
kubectl delete knp controller -n instana-kafka
kubectl delete knp kafka -n instana-kafka
kubectl delete k kafka -n instana-kafka

2. Ensure there are no existing PVCs of kafka cluster
kubectl delete pvc --all -n instana-kafka

2. recreate missing datastores:
stanctl up

Troubleshooting kafka


Kafka aliases for Instana Standard edition to issue kafka commands:
KAFPASS=`kubectl -n instana-kafka get secret instanaadmin --template='{{ index .data "password" | base64decode }}' 2>/dev/null`
kubectl -n instana-kafka exec -t kafka-kafka-1 -- bash -c "cat > /tmp/my1.conf <<-EOF
security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-512
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username='instanaadmin' password='$KAFPASS';
EOF
"

alias kt="kubectl -n instana-kafka exec po/kafka-kafka-1 -- /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --command-config /tmp/my1.conf"
alias kl="kubectl -n instana-kafka exec po/kafka-kafka-1 -- /opt/kafka/bin/kafka-log-dirs.sh --bootstrap-server localhost:9092 --command-config /tmp/my1.conf"
alias kgroups="kubectl -n instana-kafka exec po/kafka-kafka-1 -- /opt/kafka/bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --command-config /tmp/my1.conf"
alias kconf="kubectl -n instana-kafka exec po/kafka-kafka-1 -- /opt/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --command-config /tmp/my1.conf"

Example of commands for troubleshooting with defined aliases:
## Kafka topic help output
kt

## List topics
kt --list

## describe topic
kt --describe --topic raw_metrics

## Alter topic
kt --alter --topic raw_metrics --partitions 2

## Topics size
kl --describe | grep -Ev "Querying|Received" | jq

kl --describe | grep -Ev "Querying|Received" | jq '.brokers[].logDirs[].partitions[] | {partition: .partition, size: .size}'

## sorted by size in Megabytes where size is > 0Mb
kl --describe | grep -Ev "Querying|Received" | jq '.brokers[].logDirs[].partitions[] | {partition: .partition, size: (.size / (1024 * 1024)| round)} | select( all(.size; . > 0) )' | jq -s 'sort_by(.size)'

## list consumer groups
kgroups --list

## consumer gropups LAG
kgroups --group onprem_tenant0_unit0_filler-cooperative --all-topics --describe
kgroups --describe --group onprem_tenant0_unit0_filler-cooperative
kgroups --describe --all-groups | awk '{print $1, $2, $3, $6}' | column -t
kgroups --describe --group onprem_tenant0_unit0_filler --all-topics | awk '{print $1, $2, $3, $6}' | column -t

## add config example
kconf --alter --entity-type topics --entity-name onprem_tenant0_unit0_group_members --add-config retention.ms=600000


Beeinstana


Beeinstana aggregator holds longterm history and it heaviliy relies on available memory on the host as soon as by default the pod doesn't have limits. Here is how to change the configuration on the example of chaning aggregator memory requests:

Example of tuning Beeinstana aggregator


A file custom-values.yaml should have the same structure of instana-values and will be merged together before applying. So,
1. Create file ~/.stanctl/values/instana-beeinstana/custom-values.yaml
cat  << EOF > ~/.stanctl/values/instana-beeinstana/custom-values.yaml
aggregator:
  cpu: 500m
  memory: 2Gi
EOF

2. Apply changes:
stanctl datastores apply

3. Review changes:
kubectl describe beeinstana -n instana-beeinstana

Re-create Beeinstana cluster


In case of issues with beeinstana and if we're ok to loose long term metrics history we can recreate the cluster. The procedure below explains the cluster deletion and re-creation from scratch:
## delete existing kafka cluster
kubectl delete beeinstana beeinstana -n instana-beeinstana

## Ensure there are no existing PVCs of kafka cluster
kubectl delete pvc --all -n instana-beeinstana

## recreate missing datastores:
stanctl up

---
Relevant documentation:


#Administration
#Self-Hosted
#Database

0 comments
35 views

Permalink