场景: 由于基于角色的文件访问,通过RestController为Azure提供服务。
SharedKeyCredentials,HttpPipeline,ServiceURL和ContainerURL在构造函数中创建一次
public AzureSdkBlobStorageServiceImpl(AzureBlobStorageConfig azureBlobStorageConfig) throws InvalidKeyException {
SharedKeyCredentials credential = new SharedKeyCredentials(azureBlobStorageConfig.getAccountName(), azureBlobStorageConfig.getAccountKey());
HttpPipeline pipeline = StorageURL.createPipeline(credential, new PipelineOptions());
ServiceURL serviceURL = new ServiceURL(azureBlobStorageConfig.getServiceUrl(), pipeline);
containerURL = serviceURL.createContainerURL(azureBlobStorageConfig.getContainerName());
}
尝试使用SDK,并且只有在下载了Blob之后才返回。
public Blob getBlob(String identifier) {
BlockBlobURL blobURL = containerURL.createBlockBlobURL(identifier);
ByteBuffer byteBuffer = FlowableUtil.collectBytesInBuffer(blobURL.download().blockingGet().body(new ReliableDownloadOptions()))
.blockingGet();
return new Blob(identifier, byteBuffer.array());
}
将getBlob(String identifier)公开为其余端点后,一切正常。
blob-urls.txt http://localhost:8084/blob/my-image.jpg
围攻-v -c 1 -t 2m -f blob-urls.txt
Transactions: 583 hits
Availability: 100.00 %
Elapsed time: 119.65 secs
Data transferred: 1103.75 MB
Response time: 0.20 secs
Transaction rate: 4.87 trans/sec
Throughput: 9.22 MB/sec
Concurrency: 1.00
Successful transactions: 583
Failed transactions: 0
Longest transaction: 0.97
Shortest transaction: 0.15
围攻-v -c 10 -t 2m -f blob-urls.txt
Transactions: 505 hits
Availability: 100.00 %
Elapsed time: 119.18 secs
Data transferred: 956.07 MB
Response time: 2.30 secs
Transaction rate: 4.24 trans/sec
Throughput: 8.02 MB/sec
Concurrency: 9.76
Successful transactions: 505
Failed transactions: 0
Longest transaction: 8.92
Shortest transaction: 0.17
围攻-v -c 100 -t 2m -f blob-urls.txt
Transactions: 723 hits
Availability: 100.00 %
Elapsed time: 119.88 secs
Data transferred: 1368.80 MB
Response time: 15.42 secs
Transaction rate: 6.03 trans/sec
Throughput: 11.42 MB/sec
Concurrency: 93.01
Successful transactions: 723
Failed transactions: 0
Longest transaction: 45.16
Shortest transaction: 0.51
我不确定该如何解释。
从运行1和2看,似乎所有对Azure的请求都在互相等待。
但是在运行3中,吞吐量似乎更高。
从阻塞线程使用azure-storage-java V10 sdk时,是否需要为基础的httpclient配置更多线程?
总结