goose icon indicating copy to clipboard operation
goose copied to clipboard

Allow shared reqwest client configuration

Open finnefloyd opened this issue 3 years ago • 9 comments

From Reqwest official documentation:

The Client holds a connection pool internally, so it is advised that you create one and reuse it. You do not have to wrap the Client it in an Rc or Arc to reuse it, because it already uses an Arc internally.

This PR, use a shared reqwest client among all GooseUser and allow the user the configure the global client.

finnefloyd avatar Sep 01 '21 09:09 finnefloyd

Merge conflict needs to be resolved

jeremyandrews avatar Sep 02 '21 15:09 jeremyandrews

It's unclear to me if this will result in cookies and headers being shared between all GooseUsers, which would be undesirable.

jeremyandrews avatar Sep 02 '21 15:09 jeremyandrews

It's unclear to me if this will result in cookies and headers being shared between all GooseUsers, which would be undesirable.

Goose point, I did not think about it and I'm not using cookies in my current load tests, I didn't detect it. I moved the cookies handling to the GooseUser so we can shared the connection pool

finnefloyd avatar Sep 05 '21 15:09 finnefloyd

This addresses cookies, but there’s still a problem from shared headers. For example, if using http header authentication, with this PR once one GooseUser logs in all would be.

jeremyandrews avatar Sep 06 '21 05:09 jeremyandrews

For example, as documented here it's currently possible to set different headers with different GooseUsers, and this is required functionality for many load tests: https://docs.rs/goose/*/goose/goose/struct.GooseUser.html#example-18

jeremyandrews avatar Sep 06 '21 06:09 jeremyandrews

This example will also need to be updated to show how to set custom cookies: https://docs.rs/goose/*/goose/goose/struct.GooseUser.html#example-19

jeremyandrews avatar Sep 06 '21 06:09 jeremyandrews

I added support for default headers and custom cookies to the GooseUser.

finnefloyd avatar Sep 06 '21 08:09 finnefloyd

@finnefloyd Thanks for all your contributions so far!

I share Jeremy's sentiment that I would like to understand the motivation of the change a little bit more, before considering this PR.

LionsAd avatar Oct 08 '21 19:10 LionsAd

@finnefloyd Thanks for all your contributions so far!

I share Jeremy's sentiment that I would like to understand the motivation of the change a little bit more, before considering this PR.

I used Goose recently, and I needed to create thoudands of users. Starting Goose took about thirty seconds. The tests themselves were not terribly long, so the startup time was significant.

I solved this by monkey-patching goose to use a single reqwest client. (Cookies and headers weren't an issue for me.) This way the statup time disappeared.

I know this is a corner case, but IMHO worth implementing client sharing.

The general argument would be "because it's just more resource efficient".

netom avatar Dec 20 '22 09:12 netom