keolo / mixpanel_client

Ruby interface to the Mixpanel Data API
MIT License
148 stars 72 forks source link

Parallel requests options #12

Closed railwaymen closed 11 years ago

railwaymen commented 12 years ago

Hi All,

During our work with mixpanel_client we are very often need to ask Mixpanel for different stats during the one server side request. It takes so long and user needs to wait till our app will receive f.e 10 synchronous responses from Mixpanel. Our idea is to use the parallel requests aproach in such cases, so we would like to suggest to improve mixpanel_client and add :parallel option as a client config.

I've attached pull requests with optional :parallel config option(false by default) and update README with an example, If you could take a look and play around with this change and let me know what do you think about this direction of improvements.

It works fine for us, We are going to test it deeply and add some benchmark to compare parallel vs non parallel in the free time.

Let me know if you have any questions or sth is unclear.

Regards, Greg

railwaymen commented 12 years ago

I just did a quick benchmark.

user system total real mixpanel standard: 0.390000 0.020000 0.410000 ( 14.511273) mixpanel parallel: 0.050000 0.000000 0.050000 ( 2.267315)

Where "mixpanel standard" report is for 8 different requests to mixpanel server and "mixpanel parallel" includes the same 8 requests but with parallel mode enabled.

Let me know how it looks for you.

Thx, Greg

keolo commented 12 years ago

Hi Greg,

This looks interesting and useful. I'll check it out and keep you updated. Thanks.

jdg commented 11 years ago

Why wasn't this merged in?

keolo commented 11 years ago

Feel free to write specs and update to the latest Mixpanel::Client api.

jdg commented 11 years ago

Is that why it wasn't merged in 9 months ago or is there a different reason? Sorry - you didn't answer the question. :)

keolo commented 11 years ago

I think it's a good addition ... just haven't gotten around to merging in master, reviewing, and writing specs. If anyone is willing to merge master in and write specs, I'll review and release quickly.

railwaymen commented 11 years ago

Hi,

Just merge our parallel feature with a current master and added spec tests. Please review and let me know how it looks on your side.

Thx a lot Greg

keolo commented 11 years ago

Hi Greg. Thanks I'll review and merge it in in the next few days.

keolo commented 11 years ago

Thanks Greg. Your changes have made it into the 3.1.0 release.