Ceilometer db operation and optimization during alarm creation

Source: Internet
Author: User

Creating a ceilometer alarm requires 4 DB operations:

api/controllers/v2/alarms.py

1. Every time Is_over_quota needs to query all the alarms of the User/project

2. Determine if alarm name already exists in DB, and you need to query all alarms of the User/project
# Make sure alarms is unique by name per project.
Alarms = List (Conn.get_alarms (Name=data.name,
PROJECT=DATA.PROJECT_ID))
3. Add Alarm Line
Alarm = conn.create_alarm (alarm_in)

4. Add a Alarm history
Self._record_creation (conn, change, alarm.alarm_id, now)

Optimization considerations:

1. Is_over_quota, you can create a global compute data structure and lock the multi-API workers, which gets the initialization value from the DB when the service starts.

2. Determine if alarm name already exists in the DB, and name as the table's key value, you do not need to get all alarms of user/project first.

Ceilometer db operation and optimization during alarm creation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.