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.

optimiz concurrency user can customize number of workers via env "GOMAXPROCS"

guol-fnst308a48c0c206
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index a2a63acbb0..69d2492595 100644
--- a/weed/storage/disk_location.go
+++ b/weed/storage/disk_location.go
@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"runtime"
+ "strconv"
"strings"
"sync"
"time"
@@ -208,8 +209,14 @@ func (l *DiskLocation) concurrentLoadingVolumes(needleMapKind NeedleMapKind, con
func (l *DiskLocation) loadExistingVolumes(needleMapKind NeedleMapKind) {
workerNum := runtime.NumCPU()
- if workerNum <= 10 {
- workerNum = 10
+ val, ok := os.LookupEnv("GOMAXPROCS")
+ if ok {
+ num, err := strconv.Atoi(val)
+ if err != nil || num < 1 {
+ num = 10
+ glog.Warningf("failed to set worker number from GOMAXPROCS , set to default:10")
+ }
+ workerNum = num
}
l.concurrentLoadingVolumes(needleMapKind, workerNum)
glog.V(0).Infof("Store started on dir: %s with %d volumes max %d", l.Directory, len(l.volumes), l.MaxVolumeCount)