Hello!
We would like to propose introducing support for Azure Blob Storage Disks in ClickHouse, in a similar way it was done for AWS S3 Disks. At Contentsquare we have already started preliminary work to make sure this is feasible.
Context
We use S3 Disks in our AWS servers for example for storing raw data or monitoring data loss with certain metadata, for which regular disks would be too expensive. The DiskS3 approach (and not e.g. S3Engine one) is the best for us, as it can be used with MergeTrees.
Soon we will need a similar solution in Azure servers. We decided internally that the best way for us to go would be to develop for Blob Storage Disks the same logic that was developed for S3 Disks.
Note on alternatives: we considered using DataLake Gen 2, a higher abstraction built on top of Blob Storage to mimic a disk behavior, but it doesn't offer enough flexibility, for example a possibility to do a move operation, which is important for ClickHouse. We also considered using a proxy server to translate commands from S3 to Blob Storage, but it would be too error-prone and inefficient.
Work plan
Below we present what we think is necessary to add the Blob Storage Disk to ClickHouse:
- Azure SDK dependency
- POCO HTTP wrapper for Azure
- Azure authentication part
- Blob Storage buffer handling
- Blob Storage Disk
- End to end integration tests
Azure SDK dependency
We managed to add the dependency by:
- adding
azure-sdk-for-cpp directory and azure-cmake directory with custom CMakeLists.txt to contrib
- linking libraries and adding directories in
src and contrib CMakeLists.txt files
- adding Azure Blob Storage
.cmake to cmake/find and including it in the main CMakeLists.txt file
- adding a (deprecated) source file to
borignssl-cmake CMakeLists.txt, as one of its functions is used in the Azure SDK
We were able to manipulate Blob Storage from within ClickHouse with this configuration.
POCO HTTP wrapper for Azure
This part is used for communication over the network and interpretation of messages. It would be based on the S3 counterpart, with all its files located in src/IO/S3. The S3 version is quite developed and robust, for the start we could probably implement a simpler solution. We could also extract the common part with S3 and create a parent class for it.
Azure authentication part
For the start we would like to rely on the role-based authentication, in which authen is granted to an Azure instance as a whole (so there are no credentials or secrets). We have already conducted preliminary tests for this type of authentication, it is an open question whether we can leave it like that for now, as S3 implementation supports more ways to authenticate. For S3, authentication is done in src/IO/S3Common .h and .cpp.
Blob Storage buffer handling
This part is for actual reading and writing buffers for Blob Storage. For S3, these are implemented in src/IO, in fReadBufferFromS3 and WriteBufferFromS3 .h and .cpp files. It is unclear whether these need to be extracted from the Disk implementation very early on.
Blob Storage Disk
Blob Storage Disk implementation of the IDiskRemote interface, based on the equivalent src/Disk/S3 files. Regarding mutualization of the logic for Blob Storage and S3, on one hand, it might be hard, as the implementations are short and quite Disk-specific, but on the other hand, this part seems to be updated rather frequently, so it might make sense to mutualize the logic to ensure that potential fixes and refactors are applied to both Disks.
Integration tests
We would like to create a couple of end-to-end integration tests on Contentsquare use cases. We aim to run the full Azure pipeline for at least a couple of days to make sure the solution runs smoothly. Functional and unit tests are also considered.
Execution
We aim to implement this feature on our own at Contentsquare provided that we get a green light from you on the design. We have already started working on this feature and expect it to be ready in the first quarter of 2022.
Questions
- What is your general feeling about adding Azure Disk?
- Can Blob Storage Disk be started in some preliminary form and not be fully announced immediately, or shall it be full-fledged from the very release, in particular:
- Shall we extract the common part between S3 and Blob Storage in the code?
- Do we need to provide all authentication methods?
- What kind of tests are we expected to conduct?
- Any suggestions to the dependency part? We are aware of e.g. https://clickhouse.com/docs/en/development/contrib/#adding-third-party-libraries.
- Did we miss any part of the code necessary to be added?
- What is the main reason for having a POCO client for S3 if AWS already provides HTTP clients using e.g. libcurl?
Thanks for attention, let us know what you think!
Jakub Kuklis
Contentsquare
Hello!
We would like to propose introducing support for Azure Blob Storage Disks in ClickHouse, in a similar way it was done for AWS S3 Disks. At Contentsquare we have already started preliminary work to make sure this is feasible.
Context
We use S3 Disks in our AWS servers for example for storing raw data or monitoring data loss with certain metadata, for which regular disks would be too expensive. The
DiskS3approach (and not e.g.S3Engineone) is the best for us, as it can be used withMergeTrees.Soon we will need a similar solution in Azure servers. We decided internally that the best way for us to go would be to develop for Blob Storage Disks the same logic that was developed for S3 Disks.
Note on alternatives: we considered using DataLake Gen 2, a higher abstraction built on top of Blob Storage to mimic a disk behavior, but it doesn't offer enough flexibility, for example a possibility to do a move operation, which is important for ClickHouse. We also considered using a proxy server to translate commands from S3 to Blob Storage, but it would be too error-prone and inefficient.
Work plan
Below we present what we think is necessary to add the Blob Storage Disk to ClickHouse:
Azure SDK dependency
We managed to add the dependency by:
azure-sdk-for-cppdirectory andazure-cmakedirectory with customCMakeLists.txttocontribsrcandcontribCMakeLists.txtfiles.cmaketocmake/findand including it in the mainCMakeLists.txtfileborignssl-cmakeCMakeLists.txt, as one of its functions is used in the Azure SDKWe were able to manipulate Blob Storage from within ClickHouse with this configuration.
POCO HTTP wrapper for Azure
This part is used for communication over the network and interpretation of messages. It would be based on the S3 counterpart, with all its files located in src/IO/S3. The S3 version is quite developed and robust, for the start we could probably implement a simpler solution. We could also extract the common part with S3 and create a parent class for it.
Azure authentication part
For the start we would like to rely on the role-based authentication, in which authen is granted to an Azure instance as a whole (so there are no credentials or secrets). We have already conducted preliminary tests for this type of authentication, it is an open question whether we can leave it like that for now, as S3 implementation supports more ways to authenticate. For S3, authentication is done in src/IO/S3Common .h and .cpp.
Blob Storage buffer handling
This part is for actual reading and writing buffers for Blob Storage. For S3, these are implemented in src/IO, in fReadBufferFromS3 and WriteBufferFromS3 .h and .cpp files. It is unclear whether these need to be extracted from the Disk implementation very early on.
Blob Storage Disk
Blob Storage Disk implementation of the IDiskRemote interface, based on the equivalent src/Disk/S3 files. Regarding mutualization of the logic for Blob Storage and S3, on one hand, it might be hard, as the implementations are short and quite Disk-specific, but on the other hand, this part seems to be updated rather frequently, so it might make sense to mutualize the logic to ensure that potential fixes and refactors are applied to both Disks.
Integration tests
We would like to create a couple of end-to-end integration tests on Contentsquare use cases. We aim to run the full Azure pipeline for at least a couple of days to make sure the solution runs smoothly. Functional and unit tests are also considered.
Execution
We aim to implement this feature on our own at Contentsquare provided that we get a green light from you on the design. We have already started working on this feature and expect it to be ready in the first quarter of 2022.
Questions
Thanks for attention, let us know what you think!
Jakub Kuklis
Contentsquare