-
-
Notifications
You must be signed in to change notification settings - Fork 69
Proxy and Caching
Lorenzo Mangani edited this page Mar 10, 2023
·
5 revisions
When using qryn with many users and dashboards, you might want to protect against the dogpile effect by caching and distributing queries or distribute your queries and inserts across multiple nodes.
⭐ chproxy provides a fast, transparent caching proxy for qryn in front of a clickhouse server or server cluster.
wget -qO- https://github.com/Vertamedia/chproxy/releases/download/v1.14.0/chproxy-linux-amd64-v1.14.0.tar.gz | tar xvz -C /tmp
mv /tmp/chproxy /usr/local/bin/chproxy
chmod +x /usr/local/bin/chproxy
Create a configuration file for chproxy in /etc/chproxy.yml
using your clickhouse settings:
server:
http:
listen_addr: ":8124"
allowed_networks: ["127.0.0.0/24"]
users:
- name: "default"
password: "password"
to_cluster: "default"
to_user: "default"
cache: "shortterm"
clusters:
- name: "default"
nodes: ["127.0.0.1:8123"]
users:
- name: "default"
password: "password"
caches:
- name: "shortterm"
dir: "/tmp"
max_size: 150Mb
# Cached responses will expire in 130s.
expire: 130s
Create a service file in /etc/systemd/system/chproxy.service
[Unit]
Description=Clickhouse Proxy
After=network.target
[Service]
ExecStart=/usr/local/bin/chproxy -config=/etc/chproxy.yml
ExecStop=/bin/kill ${MAINPID}
Restart=on-failure
RestartSec=10s
Type=simple
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start chproxy
- Reconfigure your
qryn
instance to use the proxy port (8124
) instead of the native clickhouse port (8123
) - Restart your
qryn
service