Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Koc
Copy link
Contributor

@Koc Koc commented Dec 12, 2025

Q A
Branch? 8.1
Bug fix? no
New feature? yes
Deprecations? no
Issues -
License MIT

PHP 8.5 adds support of the persistent cURL handles which can improve performance for HTTP requests.

@carsonbot carsonbot added this to the 8.1 milestone Dec 12, 2025
@Koc Koc force-pushed the feature/shared-curl-handles branch 4 times, most recently from 2482166 to 8e06a61 Compare December 12, 2025 01:15
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this conflicts with the reset method.
It'd be strange to share the curl state between FPM processes but also reset it between requests.
The patch in this PR should remove the unset($this->share); to be consistent.
Then, we should discuss about the benefit vs risk of the shared vs insulate approach.
I don't have data about either so I'm open to more feedback.

@Koc Koc force-pushed the feature/shared-curl-handles branch from 8e06a61 to aaed9f8 Compare December 18, 2025 14:46
@Koc
Copy link
Contributor Author

Koc commented Dec 18, 2025

@nicolas-grekas nice catch. I've removed unset call in the reset method.

In our current project we do a lot of http requests. And there are too many of them has slow ssl handshake (up to 100ms). By introducton of this change we can reduce latency a lot.

There is a good video from @beberlei about that
https://www.youtube.com/watch?v=wr_Jnrc2has

@nicolas-grekas
Copy link
Member

I'm sure it can help reduce latency. I'm just wondering if it could bring some instabilities or unwanted state sharing.

/cc @jwage it'd be great if you could check this one to see how this behaves with your load!

@Koc Koc force-pushed the feature/shared-curl-handles branch from aaed9f8 to 4736d12 Compare December 19, 2025 10:51
@jwage
Copy link
Contributor

jwage commented Dec 20, 2025

I'm sure it can help reduce latency. I'm just wondering if it could bring some instabilities or unwanted state sharing.

/cc @jwage it'd be great if you could check this one to see how this behaves with your load!

Ohh I was just thinking about this exact thing this morning. So this allows us to share connections between php-fpm requests?

I'm still on 8.3 and we are upgrading to 8.4 but as soon as we get to 8.5 I will test this. I was considering proxying all http-client traffic through a sidecar proxy like envoy to get persistent connections but this would be much simpler!

Is it possible to make it opt in somehow so that we can introduce it safely and then if we have no issues, later we can change it to be enabled by default?

@Koc Koc force-pushed the feature/shared-curl-handles branch 5 times, most recently from 8f1c2e2 to 14de47a Compare December 21, 2025 23:25
@Koc
Copy link
Contributor Author

Koc commented Dec 22, 2025

@nicolas-grekas @jwage I've added configuration option (disabled by default) to enable new behavior. Please check

@OskarStark
Copy link
Contributor

So when I enable "allow", is it used or does cURL decides when to use them? Otherwise the term "allow" is misleading

@Koc Koc force-pushed the feature/shared-curl-handles branch 3 times, most recently from b803548 to 15a886e Compare January 6, 2026 12:08
@Koc Koc force-pushed the feature/shared-curl-handles branch from 15a886e to 8d26c29 Compare January 6, 2026 16:04
@nicolas-grekas nicolas-grekas force-pushed the feature/shared-curl-handles branch 2 times, most recently from 6d23a20 to 5aff9e8 Compare January 12, 2026 14:47
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I turned use_persistent_connections into a per-request extra option.
This allows possibly configuring this flag on a per-scoped-client basis, and removes the need to change anything in FrameworkBundle (extra options is an open list).

@Koc
Copy link
Contributor Author

Koc commented Jan 15, 2026

@nicolas-grekas we have false-positive violations from php-cs-fixer (again). How to deal with that?

@stof
Copy link
Member

stof commented Jan 15, 2026

I think we might want to change the formatting we use for the documentation of those options.

PHP-CS-Fixer treats line comments that are on their own line as something that should be aligned with the indentation at the place where they are, which is sensible.
The current code formatting is trying to treat multiple line comments as a multiple comment that should be aligned with the first one. This will fight with the automated formatting all the time.

@Koc
Copy link
Contributor Author

Koc commented Jan 15, 2026

I think we might want to change the formatting we use for the documentation of those options.

done ✔️ . Now all description comments located above array keys and php-cs-fixer is happy.

I've added that as a separate commit, feel free to revert it if you don't like it.

@nicolas-grekas nicolas-grekas force-pushed the feature/shared-curl-handles branch from 38e0712 to bd9f6c7 Compare January 19, 2026 17:42
@nicolas-grekas
Copy link
Member

Thank you @Koc.

@nicolas-grekas nicolas-grekas merged commit a4d18c8 into symfony:8.1 Jan 19, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants