How to Integrate Hex and Vitess Safely
Teams use hex and vitess together to run notebooks over large sharded MySQL clusters. This setup lets data analysts query production tables and build charts in one workspace. Hex acts as the collaborative notebook and app builder for your data team. Vitess scales MySQL by splitting huge tables across many database nodes. Putting them together gives analysts fast answers from big datasets. Still, direct database links from shared workspaces create security and stability risks. How data and per
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Teams use hex and vitess together to run notebooks over large sharded MySQL clusters. This setup lets data analysts query production tables and build charts in one workspace.
Hex acts as the collaborative notebook and app builder for your data team. Vitess scales MySQL by splitting huge tables across many database nodes. Putting them together gives analysts fast answers from big datasets. Still, direct database links from shared workspaces create security and stability risks.
How data and permissions flow between hex and vitess
Hex connects to a Vitess cluster through the MySQL protocol. You point the notebook workspace to the Vitess query router host and port. When an analyst runs a cell, Hex sends SQL over the network. The Vitess router parses the SQL and finds the right underlying MySQL shards.
Each shard runs its part of the query and returns rows to the router. The router merges those rows and sends the final result back to Hex. Hex caches the result in memory so Python cells can process the data. Analysts then build charts and publish apps for business users.
To log in, the workspace uses a database username and password. Vitess checks these keys against its user list before running any command. You must turn on TLS encryption so queries and results stay private in transit. Without TLS, raw data and passwords travel across the network in plain text.
Common risks with shared database accounts
Many teams set up a single shared service account for the whole workspace. Every analyst and published app then runs queries under that one database identity. When a bad query slows down the cluster, the database logs show one user. Your platform team cannot tell which person or notebook caused the outage.
Shared accounts also tend to gain broad permissions over time. One project needs access to billing tables, while another needs customer support data. Soon, the shared workspace user can read every keyspace in the cluster. Any person with edit rights in the workspace can query sensitive tables.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Unbounded queries create another major problem for sharded databases. An analyst might forget a filter and run a full scan across all shards. This heavy load can starve production apps of CPU and memory. Also, raw query results often hold sensitive fields like emails or phone numbers.
Scoping roles and network paths for safer analytics
Start by creating dedicated read-only roles in your database for notebook users. Never give a notebook account permission to write, delete, or change table schemas. Split your workspace connections by team or project instead of using one global account. Give the finance workspace role access only to finance keyspaces and tables.
Route all analytical traffic to read-only replica tablets in your Vitess cluster. Replicas handle heavy reporting queries so primary tablets can focus on live app writes. Set row limits and query timeouts on the router to stop runaway scans early. These limits keep one bad notebook cell from taking down your whole database.
Lock down network paths so the database router is not open to the internet. Allow inbound traffic only from known IP addresses or through a private network link. Review database query logs every week to spot slow scans and unused roles. When sensitive fields like card numbers or national IDs exist, apply data masking. Masking rewrites matched fields in results before they reach the notebook screen.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
How does Hex talk to a Vitess cluster?
Hex uses its standard MySQL connector to talk to the Vitess query router. The router looks like a single MySQL host to the notebook workspace. It handles all the shard routing behind the scenes.
How do we stop notebook queries from slowing down production writes?
Configure your analytics user to read only from replica tablets in the cluster. You should also set strict row limits and timeout rules on the query router. This keeps heavy scans away from primary nodes.
What is the safest way to handle PII in notebook results?
Grant access only to the specific tables each team needs for their work. Use dynamic masking to rewrite emails, phone numbers, and card numbers in query results. This keeps sensitive values out of cached notebook states.
Related guides
In this post