StackStorm / st2

StackStorm (aka "IFTTT for Ops") is event-driven automation for auto-remediation, incident responses, troubleshooting, deployments, and more for DevOps and SREs. Includes rules engine, workflow, 160 integration packs with 6000+ actions (see https://exchange.stackstorm.org) and ChatOps. Installer at https://docs.stackstorm.com/install/index.html
https://stackstorm.com/
Apache License 2.0
6.09k stars 746 forks source link

Mongodb slow query #5805

Closed chain312 closed 1 year ago

chain312 commented 2 years ago

SUMMARY

Mongodb slow query

STACKSTORM VERSION

st2 3.7.8, on python 3.8.10

OS, environment, install method

docker deployment

Steps to reproduce the problem

When I input 20,000 pieces of data at a time in a short time, the problem of slow query by mongodb occurs. It takes more than ten seconds to read a piece of data. The cpu of the host where the mongodb container is located is 32G, the memory is 128G, and the utilization rate is not high. The remaining 80% cpu. image Memory remaining 90% image Query time image Size and number of action execution scheduling queue item d b tables

3f0eb2c465156d3ef40d50ea3e55a01

Expected Results

Mongo read time is reduced so that I can run more action.

Actual Results

I entered 20,000 pieces of data into the playbook.

Thanks!

chain312 commented 1 year ago

I changed mongodb to fix this problem

nzlosh commented 1 year ago

Would you mind sharing what you changed to resolve this issue so that other people who encounter the same problem have an hint on how to resolve it?

chain312 commented 1 year ago

Would you mind sharing what you changed to resolve this issue so that other people who encounter the same problem have an hint on how to resolve it?

I have optimized the mongo sql index by creating an index in the [sort] field

arm4b commented 1 year ago

@chain312 Good to hear! Is it something you could contribute to StackStorm as a PR?

It would save you from doing the same operation for every new st2 installation and also make the community benefit from the enhancement.

chain312 commented 1 year ago

@chain312 Good to hear! Is it something you could contribute to StackStorm as a PR?

It would save you from doing the same operation for every new st2 installation and also make the community benefit from the enhancement.

Hello, mongodb tuning is not written code. Can I write it in https://github.com/StackStorm/st2docs project?

arm4b commented 1 year ago

The index creation in MongoDB is part of StackStorm initialization. See examples of the past PRs adding DB schema/index changes:

What was the index you've added?

chain312 commented 1 year ago

The index creation in MongoDB is part of StackStorm initialization. See examples of the past PRs adding DB schema/index changes:

What was the index you've added?

Thank you. I will submit the merge request later

chain312 commented 1 year ago

The index creation in MongoDB is part of StackStorm initialization. See examples of the past PRs adding DB schema/index changes:

What was the index you've added? I have submitted the code for your review Add a federated index to resolve mongo slow queries