corvus-ch / rabbitmq-cli-consumer

Consume RabbitMQ messages into any cli program
MIT License
236 stars 36 forks source link

Add option to call FastCGI through unix socket and TCP #65

Open johnduro opened 5 years ago

johnduro commented 5 years ago

Hey,

We use this consumer to execute numerous fast process in php and we realized that the startup cost of php took most of the execution time.

To resolve this issue we tried launching the process through FastGCI (PHP-FPM for this case) and we saw an improvement and now we would like to add this possibility to this consumer.

Would you consider accepting a PR adding an option to consume message though FastCGI unix socket ? default behavior would still be launching a script.

corvus-ch commented 5 years ago

Hi @johnduro,

Agreed, script startup is a factor not to be underestimated. This is specially true if throuput is essential. But before adding another complexity to this project, I suggest you have a lock at https://github.com/skolodyazhnyy/amqp-cgi-bridge. As I understand said project is doing exactly what you are asking for.

Can you please have a lock and let me know if the amqp-cgi-Bridge is suits to your needs?

johnduro commented 5 years ago

Hey,

Thanks for showing me this project, it does what we want but we use your consumer on a daily basis in production and we are pretty happy about it and about the fact that it is maintained, your quick response to issues is a good example. On the contrary amqp-cgi-bridge seems to have less users and activity
(the last commit is 9 month old).

In the light of these we would prefer to modify your consumer if i can convince you ! I think we could add this feature and keep a clean and understandable code.

Do you think it is worth a try ?

corvus-ch commented 5 years ago

Not having recent commits is not a bad thing per se but I understand what you are saying. Thanks for your trust in me and this project. Indeed I am willing to follow along with this idea.

@johnduro If I understand you correctly, you would be willing to contribute the implementation of the FastCGI feature. If that is correct, please directly contact me by email. I would like to sync your work with some other ideas I have in mind and I would like to reduce the potential for conflicts and frustration.

johnduro commented 5 years ago

great ! just sent you a mail

corvus-ch commented 5 years ago

Target branch for this feature must be https://github.com/corvus-ch/rabbitmq-cli-consumer/tree/version-3.

estahn commented 5 years ago

@corvus-ch @johnduro Is there a design spec for this feature? I don’t see how FastCGI is used here. I have a rough idea but some clarification would be good.

Also please keep in mind you ideally want to implement tcp and Unix sockets.

I have done some work with FastCGI on this project: https://github.com/hipages/php-fpm_exporter/blob/master/phpfpm/phpfpm.go#L156

corvus-ch commented 5 years ago

Is there a design spec for this feature? I don’t see how FastCGI is used here. I have a rough idea but some clarification would be good.

@estahn So far I do not have anything related to the implementation of this. The only thing I have so far is the interface I came up to bring the current shell exec and FastCGI under the same umbrella. See https://github.com/corvus-ch/rabbitmq-cli-consumer/wiki/Architecture and #68.

Also please keep in mind you ideally want to implement tcp and Unix sockets.

Yes, I agree. We should have support for both.

johnduro commented 5 years ago

@estahn @corvus-ch yes i put only socket in the issue but it should/will be available for both.

If one of you have a preference for a package to use to make those calls i'm all ears.

dkarlovi commented 4 years ago

Adding this and ability to subscribe to multiple queues (like https://github.com/skolodyazhnyy/amqp-cgi-bridge does) would make an amazing PHP-powered queue processor! <3