Click count server

    If your project uses click counting and there is some solid load on it, then you probably thought about a separate solution.

    The development history goes into one project of a sales and advertising platform, where it was necessary to take into account the number of transitions. There was a decision on PHP. But this gave a visible delay of 0.5-1 sec, which was very annoying for the developers (in particular me) and I think the users too.

    Therefore, when I had to develop a similar project, I had to look for alternatives.

    What happens when you click and take into account a click:
    - you need to pull out the transition url using a certain key
    - write data to a log or database

    Without finding industrial solutions, there were two options:
    - write a module for nginx;
    - create your own solution;

    We decided not to console nginx and created our own http server, to which requests through nginx are proxied. Although this server can act independently. Sources here

    The solution is not of an industrial nature, but so far it has proved to be quite reliable. Now being tested on a new project. During installation, you will need to correct the paths in the Makefile.

    User-friendly configuration file. You can leave most of the options unchecked. You must specify the host and port on which the server will “sit”.

    The project uses the concept of inStorage and outStorage engine. They are defined by a single interface IStorage.cpp. This is a database (storage) for storing information.

    As inStorage, memcachedb is used, in which data is stored: the key / address of the
    OutStorage uses MongoDb, which logs are written to. This functionality is optional, because access.log of the form is maintained: You can write an extension (module) for any data store using the IStorage interface. In this case, you need to change the lines in main.cpp to your class and rebuild the server. At 404 error, you can set the transition address. see config. In my project on click-server, data is proxied through nginx. I want to note that on weak hardware the server can withstand 1200rpq, which is quite enough. Almost no delay (1-3 ms). The consumed memory is 600K, so it does not require separately allocated iron. I hope this solution will be useful not only to me.
    2010/10/08 11:38:30 GET /xxx?12345 404
    2010/10/08 11:38:30 GET /leads?12345 200

    IStorage * inStorage = reinterpret_cast(new inputMcStorage);
    IStorage * outStorage = reinterpret_cast(new outputMongoStorage);

    Also popular now: