Skip to main content
Quick navigation

Field level encryption and performance

Let's demonstrate field level encryption and performance

View the full demo in realtime

You can either follow all the steps manually, or watch the recording

Review the docker compose environment

As can be seen from docker-compose.yaml the demo environment consists of the following services:

  • gateway1
  • gateway2
  • kafka-client
  • kafka1
  • kafka2
  • kafka3
  • schema-registry
cat docker-compose.yaml

Starting the docker environment

Start all your docker processes, wait for them to be up and ready, then run in background

  • --wait: Wait for services to be running|healthy. Implies detached mode.
  • --detach: Detached mode: Run containers in the background
docker compose up --detach --wait

Creating topic customers on gateway1

Creating on gateway1:

  • Topic customers with partitions:1 and replication-factor:1
kafka-topics \
--bootstrap-server localhost:6969 \
--replication-factor 1 \
--partitions 1 \
--create --if-not-exists \
--topic customers

Adding interceptor encrypt

We want to encrypt only two fields, with an in memory KMS.

step-06-encrypt-interceptor.json:

{
"kind" : "Interceptor",
"apiVersion" : "gateway/v2",
"metadata" : {
"name" : "encrypt"
},
"spec" : {
"comment" : "Adding interceptor: encrypt",
"pluginClass" : "io.conduktor.gateway.interceptor.EncryptPlugin",
"priority" : 100,
"config" : {
"fields" : [ {
"fieldName" : "password",
"keySecretId" : "password-secret",
"algorithm" : "AES128_GCM"
}, {
"fieldName" : "visa",
"keySecretId" : "visa-secret",
"algorithm" : "AES128_GCM"
} ]
}
}
}
curl \
--silent \
--request PUT "http://localhost:8888/gateway/v2/interceptor" \
--header "Content-Type: application/json" \
--user "admin:conduktor" \
--data @step-06-encrypt-interceptor.json | jq

Adding interceptor decrypt

Let's add the decrypt interceptor to decipher messages

step-07-decrypt-interceptor.json:

{
"kind" : "Interceptor",
"apiVersion" : "gateway/v2",
"metadata" : {
"name" : "decrypt"
},
"spec" : {
"comment" : "Adding interceptor: decrypt",
"pluginClass" : "io.conduktor.gateway.interceptor.DecryptPlugin",
"priority" : 100,
"config" : {
"topic" : "customers",
"kmsConfig" : {
"vault" : {
"uri" : "http://vault:8200",
"token" : "vault-plaintext-root-token",
"version" : 1
}
}
}
}
}
curl \
--silent \
--request PUT "http://localhost:8888/gateway/v2/interceptor" \
--header "Content-Type: application/json" \
--user "admin:conduktor" \
--data @step-07-decrypt-interceptor.json | jq

Listing interceptors

Listing interceptors on gateway1

curl \
--silent \
--request GET "http://localhost:8888/gateway/v2/interceptor" \
--user "admin:conduktor" | jq

Running kafka-producer-perf-test bundled with Apache Kafka

kafka-producer-perf-test \
--topic customers \
--throughput -1 \
--num-records 1000000 \
--producer-props \
bootstrap.servers=localhost:6969 \
linger.ms=100 \
compression.type=lz4 \
--producer.config ${KAFKA_CONFIG_FILE} \
--payload-file examples.json

Tearing down the docker environment

Remove all your docker processes and associated volumes

  • --volumes: Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers.
docker compose down --volumes

Conclusion

Yes, encryption in the Kafka world can be simple ... and efficient!

[!NOTE] The best part is that this performance level is with the default security provider. You can use Bouncy Castle, Conscrypt etc to boost both your performance and compliancy!