Location>code7788 >text

Online Troubleshooting - Interface not responding for a long time

Popularity:91 ℃/2024-08-20 09:58:11

Just saw the article on Fishskin.Two consecutive failures in one afternoon, who blocked our interface?I remembered a similar problem when I first joined the company.

Online interface access is not available, timeout waiting, but look at the background log is running normally, into the server to see the monitor, CPU occupancy 100%, classic interview questions!
utilizationjsp -l cap (a poem)jstack <Process PID> >I preserved the scene of the crime. I saw the problem immediately.

A large number of threads are waiting for the local method execution to complete, after understanding that the

  1. This is a piece of RSA encryption algorithm written in C. Since the data encrypted by Java RSA is inconsistent with the embedded decrypted data, the encryption and decryption are unified in C, and the local method is used to call
  2. Embedded through Bluetooth transmission to the back-end, and then transmitted to this encryption algorithm, encrypted encrypted string back to the embedded comparison data
  3. Each time this method is called, the CPU spikes to 20%, the current CPU is almost 100%, and there are no deadlocks in the algorithm
  4. Factory calls the method at high frequency for a short period of time

In summary, this is due to the frequent invocation of compute-intensive logic in a short period of time, the CPU computation, scheduling over the result, the need to do in the entrance to limit the flow of measures, and the front-end in the successive invocation of the wait for the
Understanding flow control in one article
Understand the principle and implementation of current limiting strategies in one article

As the boss urged more tightly, and the project is a single body, concurrency is not high, there is no access to Redis, tolerable interface response time is a little long, the direct use of object locks to achieve, you can also use AtomicInteger to do the restrictions

ps: the subsequent consideration of the preparation of the gateway project, the unified control of the entrance traffic

Here's a block of anti-climbing code, I don't mind articles being crawled, but please give credit where it's coming from
("Author's homepage:/Go-Solo");;
("Original source address: /Go-Solo/p/18368790");;