Entering data into storage systems
Data from mobile phones, various smart devices, or external services can come in massive numbers of small batches. Data is often transmitted through slow communication channels, whereas the communication time is limited. Yandex Data Streams receives data arriving at high frequency and speed and forms outbound data batches for the target systems, thus maintaining optimal operating modes for sources and targets. Using an API gateway to receive messages enables you to implement a custom data transmission protocol.
In this use case, the API gateway accepts incoming data and sends it to the data stream. Data is buffered in the stream and transmitted using a transfer to a cluster of ClickHouse® databases.
To set up data input:
- Prepare your cloud.
- Configure the environment.
- Create a ClickHouse® cluster.
- Create a data stream.
- Create an API gateway.
- Create a transfer.
- Test sending and receiving data.
If you no longer need data input, delete the resources used.
Prepare your cloud
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Required paid resources
The cost of supporting data input into storage systems includes:
- Fee for requests to the API gateway (see Yandex API Gateway pricing).
- Data stream maintenance fees (see Yandex Data Streams pricing).
- Fees for transmitting data between sources and targets (see Yandex Data Transfer pricing).
- Fee for a continuously running Managed Service for ClickHouse® cluster (see Managed Service for ClickHouse® pricing).
Configure the environment
Create a service account and assign it the editor
role for your folder.
Create a ClickHouse® cluster
- In the management console
, select the folder where you want to create a DB cluster. - Select Managed Service for ClickHouse®.
- Click Create cluster.
- Specify the settings for a ClickHouse® cluster:
- Under Basic parameters:
- Enter a name for the cluster.
- Select the service account you created earlier.
- Under Database, specify the DB name, username, and password.
- Under Hosts, click
. Enable Public access and click Save. - Under Additional settings, enable the following options:
- Access from Data Transfer
- Access from the management console
- Specify the remaining cluster parameters according to the instructions.
- Click Create cluster.
Wait for the cluster to start. When the cluster is ready for use, its status will change to Alive
.
Create a data stream
- In the management console
, select the folder to create a data stream in. - Select Data Streams.
- Click Create stream.
- Specify an existing serverless YDB database or create a new one. If you chose to create a new database, click Update after creating it to update the list of databases.
- Enter a name for the stream.
- Click Create.
Wait for the stream to start. When the stream is ready for use, its status will change from CREATING
to ACTIVE
.
Create an API gateway
-
On the page of the created stream, click Actions and select API Gateway.
-
Enter the name of the API gateway.
-
Under Specification, replace the
service_account_id
key value with the ID of the service account you created earlier.Save the values of the Name and Service domain fields, you will need them later.
-
Click Create.
Wait for the API gateway to start. When the API gateway is ready for use, its status will change from CREATING
to ACTIVE
.
Create a transfer
- In the management console
, select the folder where you want to create a transfer. - Select Yandex Data Transfer.
- Click Create data transfer.
- Name the transfer.
- Create a source endpoint:
- In the Source line, click Create new.
- Enter a name for the endpoint.
- In the Database type list, select
Yandex Data Streams
. - Select a database for the source.
- Enter the name of the previously created stream.
- Select the service account you created earlier.
- Click Create.
- Create a target endpoint:
- In the Target line, click Create new.
- Enter a name for the endpoint.
- In the Database type list, select
ClickHouse
. - Select the MDB cluster you created earlier.
- Enter the DB name, username, and password of the cluster you created earlier.
- Click Create.
- Click Create.
- Click
next to the name of the created transfer and select Activate.
Wait until the transfer is activated. Once the transfer is ready for use, its status will change from Creating to Replicating.
Test sending and receiving data
-
Send data to the storage system:
curl --request POST --data 'test massage' https://<url>/<paths>
Where:
<url>
: The earlier saved Service domain value of the API gateway.<paths>
: The earlier saved Name value of the API gateway.
-
In the management console
, select the Managed Service for ClickHouse® cluster you created earlier. -
On the left-hand panel, select SQL.
-
Enter the username and password and click Connect.
-
In the list, select the database you created earlier.
-
Select the DB table.
If the configuration process is successful, a record containing service data and the sent message appears in the table.
How to delete the resources you created
To stop paying for the resources you used:
- Delete the API gateway.
- Delete the transfer.
- Delete the endpoints.
- Delete the data stream.
- Delete the ClickHouse® cluster.
ClickHouse® is a registered trademark of ClickHouse, Inc