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

New http client for every beacon request #603

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

avalonche
Copy link
Collaborator

πŸ“ Summary

Use new HTTP client for every beacon node request to improve latency instead of reusing the same connection.

β›± Motivation and Context

πŸ“š References


βœ… I have run these commands

  • make lint
  • make test-race
  • go mod tidy
  • I have seen and agree to CONTRIBUTING.md

@@ -55,11 +55,9 @@ func fetchBeacon(method, url string, payload []byte, dst any, timeout *time.Dura
}
req.Header.Set("accept", "application/json")

client := http.DefaultClient
client := &http.Client{}
if timeout != nil && timeout.Seconds() > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably should change .Seconds() to .Milliseconds() while at this

Copy link
Collaborator

@metachris metachris left a comment

Choose a reason for hiding this comment

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

lgtm. i guess one other approach might be to setup one httpClient only for this, but reuse it across calls.

probably doesn't move the needle and this is good enough.

@avalonche avalonche merged commit 520e4f4 into ssz-publish-block Apr 11, 2024
2 checks passed
@avalonche avalonche deleted the new-http-client branch April 11, 2024 16:44
avalonche added a commit that referenced this pull request Apr 11, 2024
* Add flag to publish block with ssz

* profiling

* Update beaconclient/prod_beacon_instance.go

Co-authored-by: Chris Hager <chris@linuxuser.at>

* Update beaconclient/prod_beacon_instance.go

Co-authored-by: Chris Hager <chris@linuxuser.at>

* Update beaconclient/prod_beacon_instance.go

Co-authored-by: Chris Hager <chris@linuxuser.at>

* Update beaconclient/prod_beacon_instance.go

Co-authored-by: Chris Hager <chris@linuxuser.at>

* Update beaconclient/prod_beacon_instance.go

Co-authored-by: Chris Hager <chris@linuxuser.at>

* Update beaconclient/prod_beacon_instance.go

Co-authored-by: Chris Hager <chris@linuxuser.at>

* fix naming

* add slot to log

* New http client for every beacon request (#603)

* New http client for every beacon request

* use milliseconds for timeout

---------

Co-authored-by: Chris Hager <chris@linuxuser.at>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants