Skip to content
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

Listen to unix socket instead of tcp ? #2147

Closed
matthieularere-msq opened this issue Feb 3, 2022 · 9 comments
Closed

Listen to unix socket instead of tcp ? #2147

matthieularere-msq opened this issue Feb 3, 2022 · 9 comments
Labels
PBS-Java Ready For Dev Feature specification is ready to be developed.

Comments

@matthieularere-msq
Copy link

Is there currently a way to make prebid-server listen to a unix socket instead of tcp port ? My prebid-server isn't exposed but behind a app acting as a proxy to build the openrtb request send to prebid-server, so using unix socket could avoid me to reach tcp limits.

@bretg
Copy link
Contributor

bretg commented Feb 4, 2022

@matthieularere-msq - can you please elaborate on this request?

  • Prebid Server is HTTP, which is TCP.
  • Why can't you just raise the TCP limit? Or lower the keepalive?
  • Would HTTP2 connection pooling be a solution?

Sounds like you have a server running on the same box and can assume a same-box connection to PBS?

@matthieularere-msq
Copy link
Author

Indeed, it's a same-box connection to PBS.
I can try fine tune TCP but at the end the issue could reappear later as a limit would remain. That's why I thought about unix socket.
HTTP2 could worth a try. Apart from using http2 package would it requires a lot of code changes ?

@bretg
Copy link
Contributor

bretg commented Feb 4, 2022

One of the engineers will have to weigh in on whether there's much work to support HTTP2 inbound for PBS-Go and/or PBS-Java. That seems like the easiest approach here, IMO.

@SyntaxNode
Copy link
Contributor

@matthieularere-msq So you are looking to use HTTP over Unix Sockets?

There is not currently an option to listen on Unix Sockets, but I don't see a reason why not to give the Host an option. Are you interested in putting up a PR for this?

I found an example here for how to bind to Unix Sockets in Go. Looks simple. The appropriate place to implement this in PBS-Go is:

func newListener(address string, metrics metrics.MetricsEngine) (net.Listener, error) {

You would need to pass the configuration down to those calls (one for admin endpoints and another for the main endpoints). Are you using Prometheus? I haven't looked into how to add Unix Socket support on that endpoint.

I'm also cool with using HTTP2. I think PBS-Go already has support for HTTP2 incoming connections if you'd like to give it a try.

@matthieularere-msq
Copy link
Author

matthieularere-msq commented Feb 7, 2022

@SyntaxNode Thanks, I'll try to see if I manage to make unix socket work, if so I'll submit a PR.

I've tested pbs-go with http2 but it's not supported:

$ curl -I --http2-prior-knowledge http://localhost:8000/openrtb2/auction
curl: (16) Error in the HTTP2 framing layer

@SyntaxNode
Copy link
Contributor

Implemented in PBS-Go 0.208.0 by community contributor @mediasquare-alexandre.

To use this feature, set the unix_socket_enable configuration value to "true" and optionally change the unix_socket_name configuration default value from prebid-server.sock to a value of your choosing. Enabling Unix Sockets will disable the TCP endpoint, as we don't foresee a use case where both would be used.

@SyntaxNode
Copy link
Contributor

@bretg Does PBS-Java plan on adding a similar feature?

@SyntaxNode SyntaxNode added PBS-Java Ready For Dev Feature specification is ready to be developed. and removed feature request labels May 16, 2022
@bretg
Copy link
Contributor

bretg commented May 16, 2022

Maybe VertX already supports it. Adding @SerhiiNahornyi to confirm

@bretg
Copy link
Contributor

bretg commented Jun 24, 2022

Done in PBS-Java 1.91

@bretg bretg closed this as completed Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PBS-Java Ready For Dev Feature specification is ready to be developed.
Projects
None yet
Development

No branches or pull requests

3 participants