Unexplained CPU spikes on a new (empty) Postgresql Flexible Server

Arsen 0 Reputation points
2024-09-04T07:34:04.19+00:00

As mentioned in the title, we have noticed unusual regular and consistent CPU consumption percent spikes every 8 hours for about 1 hour in our PostgreSQL database server which is empty and not connected to anything. It is not in vnet and no default server settings are alternated. It runs on B2s, no geo-replication or high availability apart from the whatever is default. Backups are made once a day (default) so it cannot be that. Maintenance is scheduled to be only performed if necessary between 10pm and 7 am (also default) so it cannot be that either. The remaining credits are full as well. pg_stat_activity shows nothing unusual same as server logs show nothing out of ordinary during the spikes.

I understand it might be some internal necessary Azure operations due to the bursting nature of the compute, but it would have been nice to see the clear explanation.

Azure Database for PostgreSQL
{count} votes

1 answer

Sort by: Most helpful
  1. Vinodh247 34,661 Reputation points MVP Volunteer Moderator
    2024-09-04T10:40:29.4566667+00:00

    Hi Arsen,

    Thanks for reaching out to Microsoft Q&A.

    Given the regularity of the spikes and the lack of other activity, it’s likely that these spikes are caused by azure's internal maintenance tasks or background processes that might not be immediately visible via standard monitoring tools.

    few possibilities:

    1. Azure Infrastructure Maintenance: Even though your server is not under heavy load, Azure performs various internal maintenance tasks that could cause CPU usage spikes. These could include patching, performance optimization, or internal checks.
    2. Database Engine Tasks: PostgreSQL might be performing internal tasks such as auto-vacuuming, index maintenance, or other background processes that could contribute to periodic CPU spikes.
    3. Metrics Collection and Monitoring: Azure might periodically collect detailed metrics or perform health checks that could temporarily increase CPU usage.
    4. Bursting on B2s Tier: The B2s VM size uses burstable CPUs, which means that the server might accumulate CPU credits when idle and use them during these periodic spikes. This could manifest as a higher CPU percentage during short bursts of activity.

    Since the pg_stat_activity and server logs showing nothing unusual and that the server is not connected to anything externally, these internal tasks are the most likely causes. Unfortunately, these tasks are often not directly visible or controllable by the users, so the best approach might be to monitor the servers behavior over time and consider upgrading to a non-burstable VM size if the spikes are causing you a concern. If you want to dig deeper, you might also consider enabling more detailed logging or using Azure Monitor to track any other potential background activities that could be contributing to the spikes.

    Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.