adtracker is a persistent RESTful ad tracking service written in go (backed by redis)
go get -u github.com/aultimus/adtracker/adtracker
start redis
$ redis-server
start adtracker server
$ adtracker
ad_count and track endpoints serve as get and increment operations for the given ID example client usage:
$ curl localhost:5000/ad/foo
Can't get [adtracker/foo] from redis: redigo: nil returned
$ curl localhost:5000/ad/foo -X PUT
$ curl localhost:5000/ad/foo
{"Value":1}
$ curl localhost:5000/ad/foo -X PUT
$ curl localhost:5000/ad/foo
{"Value":2}
This service is implemented in golang as it is well suited to the webservice problem domain. Everything needed to run the http server is available in the standard library. It is also very easy to distribute, as a static binary easily obtainable. It is also more performant for a real time system under load than other choices such as python.
Redis was used as a datastore as it is in memory and therefore performant but also satisfies the persistence criteria. The simplicity of the data and queries meant that a relational database would have been uneccesary and also harder to scale.
It would be possible to scale this service horizontally onto multiple instances using a load balancer to balance traffic between adtracker instances. The multiple instances could use a single redis instance, if redis becomes a bottleneck then redis partitioning could be investigated in order to increase throughput, however this would only be necessary with extermely heavy usage.
- improve logging so it has context information related to a specific request
- vendor deps