GithubHelp home page GithubHelp logo

log-counter's Introduction

日志计数器

用途

  • 统计日志文件(比如 Nginx 的 access.log),每一个周期内,符合指定规则的日志数量(比如:用于QPS的统计;在线人数的统计)。

形式

  • 增量统计

实现原理

内存

  • 双向队列存储周期内的所有日志数据
  • 哈希表存储周期内每条日志的标识与其出现次数的关系(如果,每条日志天然不同,此处可以优化成一个整型。)

线程

开启两个线程,一个用于增量读取日志数据,将日志数据按一定规则处理,追加到双向队列,并维护哈希表;另一个用于将周期外的超时数据从双向队列的另一端移除,并维护哈希表。

使用

配置

见文件注释

执行

g++ -std=c++11 -pthread main.cpp counter
./counter

log-counter's People

Contributors

huxiaoxu2019 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.