Coder Social home page Coder Social logo

better-view-counter's Introduction

Usage

better-view-counter generates a view count badge for your repository's README. It supports a custom label and unique views only. To use it, first download the latest release. And then embed the svg like this: ![](https://yourdomain.com/badge/YOUR_USERNAME/YOUR_REPO)

Why another view counter?

When assessing other view conuters, we found they were capped at a limited number of requests per hour before the badge returned an error. This is not ideal for high-traffic repositories. Through Fiber, better-view-counter can handle about 30-40k requests per second with no cap on a 1 core vps. Memory usage also stays under 25mb during benchmarks.

Building

To build,

  1. Clone project, cd into directory
  2. go build
  3. Result will be ./viewcounter

Benchmarks

On a 1 core VPS:

./bombardier -c 750 -n 1000000 http://127.0.0.1:3000/badge/demo/demo
Statistics        Avg      Stdev        Max
  Reqs/sec     38462.53    4243.36   47245.98
  Latency       19.50ms   105.75ms      7.57s
  HTTP codes:
    1xx - 0, 2xx - 1000000, 3xx - 0, 4xx - 0, 5xx - 0
    others - 0
  Throughput:    52.80MB/s

Memory usage under 25mb.

better-view-counter's People

Contributors

fenny avatar hi019 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

better-view-counter's Issues

How does the view-counter get the client IP?

Hi, this tool is really simple and useful, thank you!

But I just have a trouble:

The application is running at default port 3000 on my VPS; the ?unique=true is applied, and I make a use of nginx to proxy it. Then I finds that the view-counter doesn't add 1 after I changed my client IP address. And it works again when the nginx is stopped (using http://ip.address directly ).

So how does the view-counter getting the client IP? Through HTTP Request Headers or something else? I have tried the CDN and added the X-Forwarded-For header but it seems not working.

Looking forward to your help. Thank you!

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.