When using a data encryption mechanism , for example, Always Encrypted with secure enclaves, we also facing a challenge that the encryption key should be rotated regularly.
To get a sense how long the key rotation process might take we performed the following test - Azure SQL Database was created in two tiers - DTU-based Standard S6 and S7.
A test table
create table [aese].demo(
id int identity primary key
, vc1 varchar(64)
, nvc1 nvarchar(64)
, nvc2 nvarchar(256)
, vb1 varbinary(512)
, d1 decimal(19,4)
, m1 money
, i1 int
, bi1 bigint
);
id int identity primary key
, vc1 varchar(64)
, nvc1 nvarchar(64)
, nvc2 nvarchar(256)
, vb1 varbinary(512)
, d1 decimal(19,4)
, m1 money
, i1 int
, bi1 bigint
);
was populated with 1000000, 5000000, and 10000000 rows.
All the columns (except the primary key) were encrypted and then re-encrypted with a new CEK.
The re-encryption time was collected.
For varchar/nvarchar/varbinary columns the random number of the same character were loaded using operations like this
replicate(N'作', ceiling( rand()*63)+1)
replicate(N'作', ceiling( rand()*63)+1)
The 'var'-type columns were populated with data consuming on average almost exactly a half of column's declared maximum length. For nvarchar columns the amount of data was double due to Unicode nature of the replicated character.
For numeric types (int, bigint, money, decimal(19,4))
Also for a small number of rows (1-5 millions) the database tier (S6 or S7) also makes a little difference.
But when the number of rows increases the higher tier (S7) significantly decreases the total time (in about 60%).
Thus, for the numeric data types a rough estimate re-encryption time is about 50 seconds per 1 million rows when using the S7 Database Tier.
For the 'var'-type columns (varchar and varbinary) the results
also show that for a small number of rows (1-5 millions) the database tier (S6 or S7) also makes a little difference.
The varchar(64) with about 33 bytes populated on average a rough estimate re-encryption time is about 43 seconds per 1 million rows when using the S7 Database Tier.
For varbinary(512) with average length about 257 bytes a rough estimate re-encryption time is about 88 seconds per 1 million rows when using the S7 Database Tier.
And finally the results for nvarchar columns
show that nvarchar(256) with average length about 257 bytes (because each character takes 2 bytes) a rough estimate re-encryption time is about 78 seconds per 1 million rows when using the S7 Database Tier.
The all test data attached below.
Comments
Post a Comment