Sending scalable data to Mixpanel
If you want to log data from your backend, you need to do it in a non-blocking way and you want it to be efficient. You could do it with CURL, but that wouldn’t really be efficient.
Enter beanstalkd, a fast, distributed, in-memory workqueue service. You can push your data to beanstalkd and use another service to process them and ping the Mixpanel api server. This lets you take care of everything in the background in a really efficient way.
We’ve put together some packages that will help you in getting started. These contain all the dependencies for beanstalkd, as well as a processing script and client libraries for PHP and Python. To download a package, enter the following command in your shell:
git clone git://github.com/mixpanel/mixpanel-php.git
git clone git://github.com/mixpanel/mixpanel-python.git
As you can see, these repos contain a fair number of packages.
Included projects (not made by Mixpanel)
- beanstalkd http://xph.us/software/beanstalkd/
- libevent http://www.monkey.org/~provos/libevent/
- pybeanstalk http://code.google.com/p/pybeanstalk/
- PyYAML http://pyyaml.org/
- simplejson http://pypi.python.org/pypi/simplejson
Once you’ve downloaded a package, you have everything you need to be up and running. Before you install the dependencies, take a quick look at what you’ve downloaded. The files you will be working with are:
logger.py or logger.php
- This is the file you will be adding to your project.
- Acts as the beanstalkd consumer; can be run as a daemon. You only need to run it.
beanstalkd (after installation)
- This file is generated once you install beanstalkd. You can move it anywhere to install.
To run an install script that takes care of everything:
sudo sh config.sh
1. Install simplejson
cd simplejson-2.0.9 sudo python setup.py install
2. Install PyYAML
sudo python setup.py install
1. Install libevent
cd ../libevent-1.4.7-stable sudo ./configure && make sudo make install sudo make verify
2. Install beanstalkd
cd ../beanstalkd-1.2 sudo ./configure && make
This will create a ‘beanstalkd’ file. To install, copy this file anywhere you
3. Install pybeanstalk
cd ../pybeanstalk-0.11.1 sudo python setup.py install
Once these are installed, you can begin to integrate Mixpanel metrics into