Hi everyone, im running Hivemq on amazon ec2 on container which has 1 cpu, 475 mb ram, 8.65 gb disk space. there i have 2 connections and total inbound publish messages are 319 and total outbound publish messages are 313. problem is that cpu is always on 100%, ram 150-200/475mb and dis space 3.70/8.65. can anyone help me identify why cpu always run on 100%?
im using my authentication extension
public class CustomAuthenticatorService implements SimpleAuthenticator {
Your high CPU usage is likely caused by the synchronous HTTP request in your authentication extension. Here’s what’s happening:
Blocking HTTP Call in Authentication
The httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()); call is blocking, meaning the authentication thread waits until the HTTP response is received.
If the authentication endpoint is slow, under high load, or has network issues, this causes delays and spikes in CPU usage.
Multiple clients trying to authenticate at the same time will worsen the issue since HiveMQ will use multiple threads waiting for these responses.
CPU Resource Constraints
Your instance only has 1 CPU and 475MB RAM, which is very limited for running HiveMQ + authentication logic.
The combination of HiveMQ handling MQTT messages and blocking HTTP requests leads to CPU saturation.
Solutions to Fix High CPU Usage
1. Use Asynchronous HTTP Requests
Instead of blocking the authentication thread, use sendAsync():