Coder Social home page Coder Social logo

gae-monitor's Introduction

Monitor

曝光监测服务。

接收曝光请求 -> 记日志 -> 投递kafka消息 -> 返回1像素透明gif图。

为什么不用Nginx

现在曝光监控的普遍做法是将1*1像素图片放到nginx下,然后通过nginx的access.log监测曝光。这么做的成本是:

  • 编译nginx(也可直接下载预编译版)
  • 配置nginx

如果不想调整nginx日志格式,也不想直接在lua中操作kafka:

  • 另启动一个进程监控nginx访问日志
  • 将访问日志格式修改成后端业务需要的格式
  • 投放消息到kafka中

或者,使用一种专门的日志传输服务将访问日志传到目标位置,但需要自研基础设施。

如果想调整nginx日志格式,直接在lua中完成kafka消息发送:

  • 编写并调试lua脚本
  • 配置nginx

可以看到,比较麻烦。使用go专门写一个监测服务有好处有:

  • 能够添加任意业务逻辑,且可维护性强(相比lua脚本)
  • 部署方便,直接执行./monitor即可(免去nginx配置)
  • 不会比nginx差很多的性能(协程、停顿<1ms的垃圾回收,、不像Java一样需要等JIT编译)

构建运行

将项目clone到$GOPATH下,然后下载依赖:

godep restore

编译:

go build gaemonitor

确保config.json与编译后的可执行文件在同一目录,然后就可以直接运行了:

./geamonitor

gae-monitor's People

Contributors

wanghongfei avatar

Stargazers

 avatar  avatar  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.