Fly.io + qryn

Fly.io + qryn

How to run qryn using Docker + ClickHouse

ยท

3 min read

image.png

If you're a Fly.io user, you can start an instance of qryn in seconds using our public Docker images and seamlessly connect it to your local or remote ClickHouse.

Requirements

  • Fly.io account and browser access to the Fly.io WebCLI

  • Any ClickHouse Service (ClickHouse Cloud, DoubleCloud, Altinity, Gigapipe)

  • Something to observe! add Logs, Metrics or Traces from anywhere

Ready? Let's get started!

Configure qryn

Configure the ENV settings to match your ClickHouse server endpoint.

flyctl secrets set CLICKHOUSE_SERVER = "your.clickhouse.server"
flyctl secrets set CLICKHOUSE_AUTH = "admin:secretpassword"
flyctl secrets set CLICKHOUSE_PROTO = "https"
flyctl secrets set CLICKHOUSE_PORT = 8443

Launch qryn

Double check your settings and deploy your qryn container.

fly launch --image qryn:latest --now

The fly launch command detects your Dockerfile and builds it.

? App Name (leave blank to use an auto-generated name):
? Select region: lax (Los Angeles, California (US))
? Would you like to deploy now? (y/N)

Choose y or run fly open to open your deployed app in a browser.

SSL/Encryption are automatically handled by the fly.io edge servers. ๐Ÿ”’

That's it! Your API instance is up and running! ๐ŸŽ‰

Usage

The system is quite boring without data. Let's insert some and start querying!

As a quick example, let's use CURL to send our first little log:

curl -X POST -H "Content-Type: application/json" \
https://your-own-qryn.fly.io/loki/api/v1/push --data '{"streams":[{"stream":{"type":"test"},"values":[["'$(date +"%s%N")'", "hello qryn"]]}]}'

๐Ÿ‘๏ธ qryn view

๐Ÿ‘๏ธ Grafana

Grafana user? No problem! qryn works using the native Loki, Tempo and Prometheus data sources available in any setup without plugins or special settings.

Scaling

The free instances should handle 100s and even 1000s of inserts per second into ClickHouse but might fall short when querying very large datasets requiring memory and time-series buffering.

image.png

You can increase instance resources using the Fly Dashboard or Fly CLI.

# Give the vm 2GB of ram
fly scale memory 2048

Auto-Scaling

Since qryn is completely stateless, multiple instances can be deployed in parallel across different regions and scaled to handle large amounts of traffic, split insert/read roles, partition users over the same ClickHouse cluster, etc.

Easy wasn't it? Learn more about all the project features and capabilities using the online documentation and enjoy your superlight, free qryn polyglot stack on Fly!

๐Ÿ“ Notes

configuration

If you'd rather build the fly.toml configuration yourself, here's a template:

# fly.toml file cloned from qryn.dev

app = "qrynjs"
primary_region = "mad"

[build]
  image = "qxip/qryn:latest"

[env]
  CLICKHOUSE_AUTH = "default:xxxxxxxxxxxx"
  CLICKHOUSE_DB = "qryn"
  CLICKHOUSE_PORT = 8443
  CLICKHOUSE_PROTO = "https"
  CLICKHOUSE_SERVER = "xxxxxxxxxx.eu-central-1.aws.clickhouse.xxx"
  HOST = "0.0.0.0"
  PORT = 3100

[[services]]
  internal_port = 3100
  protocol = "tcp"
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20

  [[services.ports]]
    handlers = ["http"]
    port = "80"

  [[services.ports]]
    handlers = ["tls", "http"]
    port = "443"

  [[services.tcp_checks]]
    interval = 10000
    timeout = 2000

That's it! Enjoy your free polyglot stack!

Running large scale and looking for an all-inclusive cloud solution? Try qryn.cloud

Did you find this article valuable?

Support qryn by becoming a sponsor. Any amount is appreciated!

ย