java - 当消息生产者生产消息的能力远远大于消息的消费者的消费能力时,该如何解决内存泄漏的问题?
PHP中文网
PHP中文网 2017-04-18 10:30:07
0
3
612

当消息生产者生产消息的能力远远大于消息的消费者的消费能力时,程序会发生什么事?

例如我这里有组桥接的生产者,每30秒会发布3700万条消息,而消费者就是一个简单的客户端,处理这3700万条消息,消费者会发生什么事?

//我知道消费者的缓冲队列会爆满溢出,导致内存泄露

怎么解决?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
小葫芦
  • First of all, this is not called a memory leak. The name is a bit loose

  • If you don’t have high reliability requirements, you can consider randomly throwing away some

  • Expansion Hardware

  • If you have requirements for reliability. To put it simply, it is thrown into the hard disk or database first. In short, it cannot be stored in the memory. It's a bit like the Socket instance in Java. There is an InputStream and OutputStream that maintain a SendQ queue and a RecvQ queue respectively, but it is in memory and we just put it on the hard disk.

大家讲道理

Isn’t there one RejectedExecutionHandler?

黄舟

Even if the memory is leaked, the computer still doesn’t crash. RejectedExecutionHandler handles rejected tasks, why not use redis, haha

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template