SShortSingh.
Back to feed

How Engineers Ran Vector Search on a $5 VPS by Fixing SQLite Memory Leaks

0
·1 views

Developers building the NetGlyph Knowledge Protocol (NGP 4.5) set out to run a distributed AI vector search engine on a low-cost virtual machine with just 2GB of RAM and no swap space. Rather than using memory-intensive solutions like pgvector or Pinecone, they opted for SQLite as a lightweight alternative. A critical bug was discovered in an AI agent called Hermes, which was silently opening new database connections to fetch timestamps without ever closing them, causing file descriptor leaks that exhausted system resources after processing around 2,258 documents. The fix involved replacing SQL-based time queries with native Python calls and enforcing proper connection handling using context managers to guarantee descriptor closure. These changes stabilized memory consumption and allowed the system to handle hundreds of transactions per second without triggering out-of-memory crashes.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Playwright Browser-Mode Fix Stops Excluded Plugins Being Updated and Triggering False Alerts

A bug in a Playwright-based WordPress maintenance tool caused plugins marked as excluded from updates to be updated anyway during browser-mode runs, including as a residual pass after SSH-based updates. The root cause was a select-all checkbox approach on WordPress's update-core.php page that never consulted the excluded plugins list. Additionally, the post-update residual check incorrectly flagged intentionally skipped plugins as pending updates, generating misleading warning emails. The fix introduces per-checkbox evaluation that extracts each plugin's slug and skips it if found in the exclusion list, mirroring the filtering already applied via WP-CLI on SSH-capable sites. A separate residual-state function was also updated so that only excluded plugins remaining on the update page no longer trigger a warning.

0
ProgrammingDEV Community ·

Run Multiple Python Bots on One Railway Service Using StayPresent

Developers running multiple related Python bots on Railway typically deploy each as a separate service, doubling hosting costs and configuration overhead. A tutorial published on DEV Community demonstrates how to consolidate two or more bots — such as a Telegram and a Discord bot — into a single Railway container using a Python library called StayPresent. The setup requires a central entry point file that launches each bot as an independently monitored subprocess, meaning a crash in one bot does not affect the others. StayPresent also handles Railway's HTTP port requirement and exposes a status endpoint showing uptime and restart counts for each bot. The approach is described as compatible with other PaaS platforms like Render and Koyeb as well.

0
ProgrammingDEV Community ·

How to Keep a Discord Bot Running on Render's Free Tier Using StayPresent

Discord bots deployed on Render's free tier frequently go offline because Render's health checker expects an HTTP response on an open port, which a standard discord.py bot never provides. Without a responding port, Render marks the service as unhealthy and repeatedly restarts or spins it down. The fix involves installing the StayPresent library, creating a new entry point file that binds to Render's assigned PORT environment variable and serves a basic health response, then updating the start command in Render's service settings. An optional self-ping feature can also be configured to prevent the service from sleeping due to inactivity on Render's free tier. The bot's core Discord logic requires no changes — only the entry point Render uses to launch the application is new.

0
ProgrammingDEV Community ·

StayPresent Offers Crash Recovery and Status Pages for Bots at No Cost

StayPresent is an open-source Python library that provides crash recovery, hang detection, and status page generation for bot developers, released under the permissive MIT License. Unlike many free developer tools, it operates entirely within a user's own deployment with no external servers, API keys, or third-party services involved. Because there is no hosted infrastructure on the vendor's side, there is no ongoing cost that would create pressure to introduce paid tiers or feature restrictions. The tool is available via pip and carries no account requirements, usage limits, or hidden upgrades. Developers trade the convenience of a managed external service for full control over their own monitoring data and infrastructure.

How Engineers Ran Vector Search on a $5 VPS by Fixing SQLite Memory Leaks · ShortSingh