Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

reusing http connections

Chris Luc3ce024fc1a1
diff --git a/go/operation/upload_content.go b/go/operation/upload_content.go
index 17fe9e1c3c..7d88b37211 100644
--- a/go/operation/upload_content.go
+++ b/go/operation/upload_content.go
@@ -21,6 +21,16 @@ type UploadResult struct {
Error string
}
+var (
+ client *http.Client
+)
+
+func init() {
+ client = &http.Client{Transport: &http.Transport{
+ MaxIdleConnsPerHost: 1024,
+ }}
+}
+
var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"")
func Upload(uploadUrl string, filename string, reader io.Reader, isGzipped bool, mtype string) (*UploadResult, error) {
@@ -57,7 +67,7 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
glog.V(0).Infoln("error closing body", err)
return nil, err
}
- resp, err := http.Post(uploadUrl, content_type, body_buf)
+ resp, err := client.Post(uploadUrl, content_type, body_buf)
if err != nil {
glog.V(0).Infoln("failing to upload to", uploadUrl, err.Error())
return nil, err