Final upload rate calculated {"key

Final upload rate calculated {"key": "7593/320123", "second": 1, "rate_MBps": 7.789717271412793, "bytes_uploaded": 578944048, "elapsed_seconds": 70.878576202} @cmaddox
8 Replies
cmaddox
cmaddox3mo ago
It looks like most of the time we are waiting on the client to send us bytes. You might need to tweak your config a little bit to maximize your network link
Carlos Peliciari
Carlos PeliciariOP3mo ago
I'm just using the AWS SDK.
package cloudflare

import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.uber.org/zap"
"io"
"log"
"os"
"time"
)


func (s *S3) UploadFile(ctx context.Context, key string, localPath string) error {
file, err := os.Open(localPath)
if err != nil {
return fmt.Errorf("fail to open file %s: %w", localPath, err)
}
defer file.Close()

uploader := manager.NewUploader(s.client, func(u *manager.Uploader) {
u.PartSize = 10 * 1024 * 1024
u.Concurrency = 10
})

_, err = uploader.Upload(ctx, &s3.PutObjectInput{
Bucket: aws.String(s.bucket),
Key: aws.String(key),
Body: file,
})
if err != nil {
return fmt.Errorf("failed to upload %s: %w", key, err)
}

return nil
}
package cloudflare

import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.uber.org/zap"
"io"
"log"
"os"
"time"
)


func (s *S3) UploadFile(ctx context.Context, key string, localPath string) error {
file, err := os.Open(localPath)
if err != nil {
return fmt.Errorf("fail to open file %s: %w", localPath, err)
}
defer file.Close()

uploader := manager.NewUploader(s.client, func(u *manager.Uploader) {
u.PartSize = 10 * 1024 * 1024
u.Concurrency = 10
})

_, err = uploader.Upload(ctx, &s3.PutObjectInput{
Bucket: aws.String(s.bucket),
Key: aws.String(key),
Body: file,
})
if err != nil {
return fmt.Errorf("failed to upload %s: %w", key, err)
}

return nil
}
Carlos Peliciari
Carlos PeliciariOP3mo ago
No description
Carlos Peliciari
Carlos PeliciariOP3mo ago
I just saw here, it seems that I have a loss for cloudflare.
Carlos Peliciari
Carlos PeliciariOP3mo ago
I changed the server, but I still have low upload speeds
2025-09-18T00:45:43.969Z INFO cloudflare/s3.go:315 Final upload rate calculated {"key": "7593/318494", "second": 1, "rate_MBps": 9.761469034294421, "bytes_uploaded": 703103040, "elapsed_seconds": 68.691639412}
2025-09-18T00:45:43.969Z INFO cloudflare/s3.go:315 Final upload rate calculated {"key": "7593/318494", "second": 1, "rate_MBps": 9.761469034294421, "bytes_uploaded": 703103040, "elapsed_seconds": 68.691639412}
No description
No description
Carlos Peliciari
Carlos PeliciariOP3mo ago
@cmaddox Another thing, is there any priority support for R2, or is the support here on discord?
cmaddox
cmaddox3mo ago
Not sure, I believe if you are ENT you get support. Support through here is a bit random, like if we happen to be on and see something, but it's certainly not guaranteed. I'm still seeing the same thing. I'd maybe try to mess with the concurrency/part size a bit. The other option would be to implement a solution in go using streams. The go aws sdk might be buffering the file before trying to send it.
Carlos Peliciari
Carlos PeliciariOP3mo ago
I'm trying everything I can with the aws golang implementation but the upload is always low.
package cloudflare

import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.uber.org/zap"
"io"
"log"
"os"
"time"
)

type Config struct {
BucketName string `mapstructure:"bucket_name"`
AccountId string `mapstructure:"account_id"`
AccessKeyId string `mapstructure:"access_key_id"`
AccessKeySecret string `mapstructure:"access_key_secret"`
}

type S3 struct {
client *s3.Client
bucket string
}

func NewS3(cfg *Config) (*S3, error) {
s3cfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(cfg.AccessKeyId, cfg.AccessKeySecret, "")),
config.WithRegion("auto"),
)
if err != nil {
log.Fatal(err)
}

client := s3.NewFromConfig(s3cfg, func(o *s3.Options) {
o.BaseEndpoint = aws.String(fmt.Sprintf("https://%s.r2.cloudflarestorage.com", cfg.AccountId))
})

return &S3{
client: client,
bucket: cfg.BucketName,
}, nil
}

func (s *S3) UploadFile(ctx context.Context, key string, localPath string) error {
file, err := os.Open(localPath)
if err != nil {
return fmt.Errorf("fail to open file %s: %w", localPath, err)
}
defer file.Close()

uploader := manager.NewUploader(s.client, func(u *manager.Uploader) {
u.PartSize = 10 * 1024 * 1024
u.Concurrency = 100
})

_, err = uploader.Upload(ctx, &s3.PutObjectInput{
Bucket: aws.String(s.bucket),
Key: aws.String(key),
Body: file,
})
if err != nil {
return fmt.Errorf("failed to upload %s: %w", key, err)
}

return nil
}
package cloudflare

import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.uber.org/zap"
"io"
"log"
"os"
"time"
)

type Config struct {
BucketName string `mapstructure:"bucket_name"`
AccountId string `mapstructure:"account_id"`
AccessKeyId string `mapstructure:"access_key_id"`
AccessKeySecret string `mapstructure:"access_key_secret"`
}

type S3 struct {
client *s3.Client
bucket string
}

func NewS3(cfg *Config) (*S3, error) {
s3cfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(cfg.AccessKeyId, cfg.AccessKeySecret, "")),
config.WithRegion("auto"),
)
if err != nil {
log.Fatal(err)
}

client := s3.NewFromConfig(s3cfg, func(o *s3.Options) {
o.BaseEndpoint = aws.String(fmt.Sprintf("https://%s.r2.cloudflarestorage.com", cfg.AccountId))
})

return &S3{
client: client,
bucket: cfg.BucketName,
}, nil
}

func (s *S3) UploadFile(ctx context.Context, key string, localPath string) error {
file, err := os.Open(localPath)
if err != nil {
return fmt.Errorf("fail to open file %s: %w", localPath, err)
}
defer file.Close()

uploader := manager.NewUploader(s.client, func(u *manager.Uploader) {
u.PartSize = 10 * 1024 * 1024
u.Concurrency = 100
})

_, err = uploader.Upload(ctx, &s3.PutObjectInput{
Bucket: aws.String(s.bucket),
Key: aws.String(key),
Body: file,
})
if err != nil {
return fmt.Errorf("failed to upload %s: %w", key, err)
}

return nil
}
It's very strange, I've tried several servers in different data centers, all machines with 10Gbps Is there any limitation on cloudflare account? Would you have any suggestions? this done

Did you find this page helpful?