使用来自阻塞线程的azure-storage-java V10的吞吐量

时间:2019-03-05 09:46:07

标签: java azure azure-storage

场景: 由于基于角色的文件访问,通过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

1。 AzureSdkBlobStorageServiceImpl与1个并发用户持续2分钟

围攻-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

2。 AzureSdkBlobStorageServiceImpl vs 10个并发用户2分钟

围攻-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

3。 AzureSdkBlobStorageServiceImpl vs 100个并发用户2分钟

围攻-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配置更多线程?

总结

  • 此刻我无法更改调用代码,所以我想我被迫做blockingGet()?
  • 是否可以使用azure-storage-java V10 sdk来提高吞吐量?
  • 我做错了吗?

0 个答案:

没有答案