Comments (6)
是8K啊 不是80K. 日志量持续超过硬盘写能力 就会爆炸!
from log4z.
恩,也就是说生产者和消费者不是平衡的,3秒就爆了.
from log4z.
这个问题准备改进么?或者是设计如此?
from log4z.
如果采用异步写日志 就会有这个超负载的问题.
log4z 应用场景是服务器debug日志, 这个量和硬盘的顺序写入能力相比 是很小的, 就是说 实际上log4z的目标使用环境中不会出现这种情况.
延伸一下 即使用在客户端或者移动客户端 也是同样的不会出现.
另外 log4z支持同步写日志 因为不存在异步 所以也不会有这个问题.
目前唯一的考量是 可以做一个保护. 但这个保护是有代价的, 即 在超出某个阈值后 主动丢弃新写入的日志, 保证log4z占用的内存小于一个阈值.
目前没有收到更多的关于这个问题的反馈, 我自己几个项目的使用也不存在这些问题 最近想节省出一些时间LOL .
from log4z.
好的,明白了.
如果量不是很大的情况下,这个问题是不存在的.(出现问题的原因,还是生产者消费者不平衡)
但是我觉得这种模式始终会有问题,算法始终要考虑一些极端的情况,
我个人认为如果超过阈值就启用及时写入来清理占用的内存.
from log4z.
即时写入并不能解决这个问题, log4z的写入检查间隔是50ms(休眠), 但进入下次休眠的前提是写空日志队列.
问题的表现是 log4z已经来不及去休眠 持续写入硬盘的情况下仍然不能写空日志队列,并且日志队列的数据还在随着push超额增加. 和休眠没有任何关系.
问题的原因是 日志量超过了硬盘写入负荷.
之所以造成日志量超过硬盘写入负荷的原因,以及对应的解决方案是使用者的问题, log4z这里能做到的 是提供一个宏定义控制的, 在通常情况下一个相对小的问题来替换掉这个问题 即 超出硬盘负荷后丢弃后续日志, 以丢弃超出阈值后的日志为代价保证程序不因日志写入问题造成内存使用殆尽.
在8.25号的更新中 添加了一个宏定义 默认阈值是队列size < 10000 , 也就是说日志队列极端情况下最多占用约80M内存.
commit: 16c209c
from log4z.
Related Issues (20)
- 建议封装成动态库 HOT 2
- 怎么输出进程线程ID啊?还有就是输出的顺序有点问题? HOT 1
- 进程长时间不写(跨天),重新新建log文件写入的问题 HOT 1
- 是否支持中文路径? HOT 1
- android compile err.error: 'gcvt' was not declared in this scope. HOT 3
- Thread_local is not supported for iOS 8.4 or earlier. It will cause a compile error in Xcode HOT 1
- 'isnan' was not declared in this scope if (isnan(t)) ;这样的问题怎么解决? HOT 1
- DynamicCreateLogger 接口缺失 HOT 2
- 在VS下断点调试时,并不能立即输出 HOT 2
- API reference is missed HOT 2
- 如何限制日志的大小呢? HOT 1
- error C3861: 'isnan': identifier not found HOT 1
- 日志自动清除 HOT 2
- 可以指定文件名格式和文件夹格式吗
- Log4zFileHandler::open不支持单个2GB以上的文件
- Mismatch (malloc vs operator delete)
- 这个是不是多线写日志文件 自旋锁导致的问题 程序崩溃?
- log4z thread mutex bug? HOT 1
- 请问单条日志容量如何设定?
- Does log4z clear old logs in the logfolder? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from log4z.