-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[phpkafka] How to make persistent connections? #419
Comments
I dont know much about the PHP bindings, but it sounds like a new client handle is constructed for each produced message, which definately isn't right. Check to see if you are properly holding on and reusing your kafka handle. I think you should file this issue on phpkafka instead. |
Thank you @edenhill! I think this is the problem, as we are publishing messages on a web based aplication, every request we need to create a new connection, but i'm trying to find a way to reuse the same connection. If you guys @edenhill @EVODelavega @arnaud-lb have some suggestion, will be nice, thanks! |
Hi @viniciuswebdev, In php-rdkafka, there is only one Connections are not persistent across multiple PHP requests though; however it could be easy to change php-rdkafka to allow re-using |
@viniciuswebdev Reusing the same connection over various requests isn't really feasible. PHP is a stateless environment, so keeping a connection alive in between requests is not really supported. Of course, if you're using PHP-FPM, it could be possible for us to add a kafka connection pool to the extension, that can be accessed in a specific way. But features like that require aren't considered high-priority to implement. What you could do instead, though, is to use something like react/reactPHP to have a php process with an active connection to Kafka and interact with that. React will keep the PHP processes (and all of its resources) alive. |
@arnaud-lb The risk with re-using kafka connections are quite similar to, for example, the old mysql extension:
I Really don't think this is going to be an easy thing to implement, because it changes the way In my opinion, persistent connections are not a good idea, certainly not in PHP. A stateless environment shouldn't keep resources alive in between requests. The only thing PHP can persist in between requests is extension/module setup that you can safely put in |
@EVODelavega as described in this url :arnaud-lb/php-rdkafka#14, I found phpkafka also has the similar problem, can you help me ,thanks |
Hey guys,
I'm testing some libs to publish with PHP to kafka, but I noticed that every message published a connection is open on Kafka, there is a way to use the same connection open at the first message?
Or is it a configuration on Kafka?
Thanks!!!
The text was updated successfully, but these errors were encountered: