[{"data":1,"prerenderedAt":633},["ShallowReactive",2],{"blog-running-two-graphpg-apis-on-a-3-dollar-vps":3,"blog-running-two-graphpg-apis-on-a-3-dollar-vps-favor-of":632},{"id":4,"title":5,"body":6,"cover_image":615,"date":616,"description":617,"extension":618,"meta":619,"navigation":621,"path":622,"seo":623,"stem":624,"tags":625,"type":630,"__hash__":631},"blog\u002Fblog\u002Frunning-two-graphpg-apis-on-a-3-dollar-vps.md","Running Two GraphPG APIs on One 3-Dollar UpCloud VPS",{"type":7,"value":8,"toc":609},"minimark",[9,13,42,61,64,69,77,101,108,112,133,270,276,470,484,488,521,561,567,571,583,593,605],[10,11,5],"h1",{"id":12},"running-two-graphpg-apis-on-one-3-dollar-upcloud-vps",[14,15,16,17,21,22,29,30,35,36,41],"p",{},"Most product demos end up costing more to keep online than the traffic justifies, because every small showcase app drags along its own managed database and runtime container. Teams usually handle that by spinning up a separate small database and compute service per project, which works until a handful of interactive demos costs real money just to sit idle. In this guide I walk through the exact setup I put together in ",[18,19,20],"code",{},"infra-demo"," to host two separate PostgreSQL 18 demo databases, for ",[23,24,28],"a",{"href":25,"rel":26},"https:\u002F\u002Fretroagile.com\u002Fdemo",[27],"nofollow","RetroAgile"," and ",[23,31,34],{"href":32,"rel":33},"https:\u002F\u002Finnovi.care\u002Fdemo",[27],"Innovi Care",", on a single €3\u002Fmonth UpCloud virtual machine behind ",[23,37,40],{"href":38,"rel":39},"https:\u002F\u002Fmihailtd.github.io\u002Fgraphpg\u002F",[27],"graphpg"," and a Cloudflare Tunnel.",[14,43,44,45,50,51,54,55,60],{},"If you have seen my earlier ",[23,46,49],{"href":47,"rel":48},"https:\u002F\u002Finnovi.pro\u002Fblog\u002Fn8n-production-reference-architecture",[27],"n8n reference setup on UpCloud",", you already know the ",[18,52,53],{},"DEV-1xCPU-1GB-10GB"," tier: one vCPU, 1 GB of memory, 10 GB of disk, and clean Terraform and Pulumi support. Back in October, when I timed schema startup on a 173-table FHIR R5 schema against PostgreSQL 18.6, graphpg built the schema in 85 ms while PostGraphile took 880 ms (",[23,56,59],{"href":57,"rel":58},"https:\u002F\u002Finnovi.pro\u002Fblog\u002Fagentic-software-factory-fhir-graphpg",[27],"Innovi Pro write-up","). Because that Rust binary starts fast and avoids GC heap growth, co-hosting two small APIs alongside one Postgres engine looked realistic on 1 GB of RAM as long as memory limits stayed explicit.",[62,63],"hr",{},[65,66,68],"h2",{"id":67},"why-two-small-rust-servers-fit-where-heavier-stacks-swap","Why two small Rust servers fit where heavier stacks swap",[14,70,71,72,76],{},"A Node.js GraphQL server plus a separate REST layer tends to eat several hundred megabytes of heap before the first request arrives, and running two copies of that stack alongside Postgres usually triggers out-of-memory kills on a 1 GB box. Compiled Rust services do not carry a garbage-collected VM, and graphpg serves both GraphQL and OpenAPI REST from one plan that compiles every selection into a single SQL statement (",[23,73,75],{"href":38,"rel":74},[27],"graphpg engine overview",").",[14,78,79,80,84,85,88,89,92,93,96,97,100],{},"Because PostgreSQL handles concurrency and row visibility cleanly on its own, splitting two demo apps across two separate databases inside ",[81,82,83],"strong",{},"one"," ",[18,86,87],{},"postgres:18-alpine"," process saves a whole database engine's shared memory. Instead of two Postgres instances fighting over page cache, one ",[18,90,91],{},"shared_buffers"," pool serves both the ",[18,94,95],{},"retroagile"," database and the ",[18,98,99],{},"innovi_care"," database.",[14,102,103],{},[104,105],"img",{"alt":106,"src":107},"Four-stage container memory budget on one 1 GB UpCloud server: Cloudflare Tunnel (96m) feeds two graphpg 1.3.0 services (96m each), both backed by one PostgreSQL 18 container (320m) within 608 MB total ceilings.","\u002Fimages\u002Fblog\u002Fvps-memory-budget-poster.png",[65,109,111],{"id":110},"setting-explicit-memory-ceilings-inside-docker-compose","Setting explicit memory ceilings inside Docker Compose",[14,113,114,115,120,121,124,125,128,129,132],{},"Without container limits, PostgreSQL's background workers or a burst of concurrent queries can starve small helper daemons. In the ",[23,116,119],{"href":117,"rel":118},"https:\u002F\u002Fgithub.com\u002Fmihailtd\u002Fretroagile\u002Ftree\u002Fmain\u002Fpackages\u002Finfra-demo",[27],"RetroAgile infra-demo stack",", ",[18,122,123],{},"docker-compose.vps.yml"," pins hard cgroup ",[18,126,127],{},"mem_limit"," bounds so the steady-state total stays at ",[81,130,131],{},"608 MB",", leaving roughly 416 MB of physical memory for Linux page cache alongside a 1 GB disk swap file created by cloud-init.",[134,135,136,157],"table",{},[137,138,139],"thead",{},[140,141,142,146,149,154],"tr",{},[143,144,145],"th",{},"Service",[143,147,148],{},"Image",[143,150,152],{"align":151},"right",[18,153,127],{},[143,155,156],{},"Role on the VPS",[158,159,160,184,211,233,252],"tbody",{},[140,161,162,168,172,177],{},[163,164,165],"td",{},[18,166,167],{},"postgres",[163,169,170],{},[18,171,87],{},[163,173,174],{"align":151},[18,175,176],{},"320m",[163,178,179,180,29,182],{},"Single instance serving ",[18,181,95],{},[18,183,99],{},[140,185,186,191,196,201],{},[163,187,188],{},[18,189,190],{},"graphpg-retroagile",[163,192,193],{},[18,194,195],{},"ghcr.io\u002Fmihailtd\u002Fgraphpg:1.3.0",[163,197,198],{"align":151},[18,199,200],{},"96m",[163,202,203,204,207,208,210],{},"Bound to ",[18,205,206],{},"127.0.0.1:8081"," (",[18,209,95],{}," DB)",[140,212,213,218,222,226],{},[163,214,215],{},[18,216,217],{},"graphpg-innovi-care",[163,219,220],{},[18,221,195],{},[163,223,224],{"align":151},[18,225,200],{},[163,227,203,228,207,231,210],{},[18,229,230],{},"127.0.0.1:8082",[18,232,99],{},[140,234,235,240,245,249],{},[163,236,237],{},[18,238,239],{},"cloudflared",[163,241,242],{},[18,243,244],{},"cloudflare\u002Fcloudflared:latest",[163,246,247],{"align":151},[18,248,200],{},[163,250,251],{},"Outbound Argo Tunnel to Cloudflare Edge",[140,253,254,259,263,267],{},[163,255,256],{},[18,257,258],{},"db-migrate-seed",[163,260,261],{},[18,262,87],{},[163,264,265],{"align":151},[18,266,200],{},[163,268,269],{},"One-shot init applying Drizzle SQL and reset RPCs",[14,271,272,273,275],{},"Here is the Postgres flag tuning inside ",[18,274,123],{}," that keeps memory predictable under light demo load:",[277,278,283],"pre",{"className":279,"code":280,"language":281,"meta":282,"style":282},"language-yaml shiki shiki-themes github-dark-default","postgres:\n  image: postgres:18-alpine\n  restart: unless-stopped\n  mem_limit: 320m\n  command:\n    - postgres\n    - -c\n    - shared_buffers=192MB\n    - -c\n    - work_mem=4MB\n    - -c\n    - maintenance_work_mem=32MB\n    - -c\n    - effective_cache_size=384MB\n    - -c\n    - max_connections=40\n    - -c\n    - wal_level=minimal\n    - -c\n    - max_wal_senders=0\n    - -c\n    - synchronous_commit=off\n","yaml","",[18,284,285,297,310,321,332,340,349,357,365,372,380,387,395,402,410,417,425,432,440,447,455,462],{"__ignoreMap":282},[286,287,290,293],"span",{"class":288,"line":289},"line",1,[286,291,167],{"class":292},"sPWt5",[286,294,296],{"class":295},"sZEs4",":\n",[286,298,300,303,306],{"class":288,"line":299},2,[286,301,302],{"class":292},"  image",[286,304,305],{"class":295},": ",[286,307,309],{"class":308},"s9uIt","postgres:18-alpine\n",[286,311,313,316,318],{"class":288,"line":312},3,[286,314,315],{"class":292},"  restart",[286,317,305],{"class":295},[286,319,320],{"class":308},"unless-stopped\n",[286,322,324,327,329],{"class":288,"line":323},4,[286,325,326],{"class":292},"  mem_limit",[286,328,305],{"class":295},[286,330,331],{"class":308},"320m\n",[286,333,335,338],{"class":288,"line":334},5,[286,336,337],{"class":292},"  command",[286,339,296],{"class":295},[286,341,343,346],{"class":288,"line":342},6,[286,344,345],{"class":295},"    - ",[286,347,348],{"class":308},"postgres\n",[286,350,352,354],{"class":288,"line":351},7,[286,353,345],{"class":295},[286,355,356],{"class":308},"-c\n",[286,358,360,362],{"class":288,"line":359},8,[286,361,345],{"class":295},[286,363,364],{"class":308},"shared_buffers=192MB\n",[286,366,368,370],{"class":288,"line":367},9,[286,369,345],{"class":295},[286,371,356],{"class":308},[286,373,375,377],{"class":288,"line":374},10,[286,376,345],{"class":295},[286,378,379],{"class":308},"work_mem=4MB\n",[286,381,383,385],{"class":288,"line":382},11,[286,384,345],{"class":295},[286,386,356],{"class":308},[286,388,390,392],{"class":288,"line":389},12,[286,391,345],{"class":295},[286,393,394],{"class":308},"maintenance_work_mem=32MB\n",[286,396,398,400],{"class":288,"line":397},13,[286,399,345],{"class":295},[286,401,356],{"class":308},[286,403,405,407],{"class":288,"line":404},14,[286,406,345],{"class":295},[286,408,409],{"class":308},"effective_cache_size=384MB\n",[286,411,413,415],{"class":288,"line":412},15,[286,414,345],{"class":295},[286,416,356],{"class":308},[286,418,420,422],{"class":288,"line":419},16,[286,421,345],{"class":295},[286,423,424],{"class":308},"max_connections=40\n",[286,426,428,430],{"class":288,"line":427},17,[286,429,345],{"class":295},[286,431,356],{"class":308},[286,433,435,437],{"class":288,"line":434},18,[286,436,345],{"class":295},[286,438,439],{"class":308},"wal_level=minimal\n",[286,441,443,445],{"class":288,"line":442},19,[286,444,345],{"class":295},[286,446,356],{"class":308},[286,448,450,452],{"class":288,"line":449},20,[286,451,345],{"class":295},[286,453,454],{"class":308},"max_wal_senders=0\n",[286,456,458,460],{"class":288,"line":457},21,[286,459,345],{"class":295},[286,461,356],{"class":308},[286,463,465,467],{"class":288,"line":464},22,[286,466,345],{"class":295},[286,468,469],{"class":308},"synchronous_commit=off\n",[14,471,472,473,120,476,479,480,483],{},"PRO Tip #1: Ephemeral demo databases do not need replication slots or point-in-time recovery, because seed scripts recreate them cleanly from Drizzle migrations. Setting ",[18,474,475],{},"wal_level=minimal",[18,477,478],{},"max_wal_senders=0",", and ",[18,481,482],{},"synchronous_commit=off"," avoids extra background WAL overhead while keeping container startup fast.",[65,485,487],{"id":486},"routing-two-databases-through-one-private-tunnel","Routing two databases through one private tunnel",[14,489,490,491,29,493,495,496,499,500,502,503,29,506,509,510,512,513,29,515,517,518,520],{},"Once Postgres initializes both ",[18,492,95],{},[18,494,99],{}," via ",[18,497,498],{},"00-init-multi-db.sql",", a one-shot ",[18,501,258],{}," container applies each repo's Drizzle SQL files and runs ",[18,504,505],{},"reset_retroagile_demo()",[18,507,508],{},"reset_innovi_care_demo()",". Neither ",[18,511,40],{}," container binds a public interface: each listens on loopback (",[18,514,206],{},[18,516,230],{},"), while ",[18,519,239],{}," opens an outbound tunnel to Cloudflare and terminates TLS at the edge.",[14,522,523,524,29,528,532,533,29,536,539,540,29,543,546,547,120,550,479,553,556,557,560],{},"On the application side, the Cloudflare Worker SSR sites at ",[23,525,527],{"href":25,"rel":526},[27],"retroagile.com\u002Fdemo",[23,529,531],{"href":32,"rel":530},[27],"innovi.care\u002Fdemo"," send server-to-server GraphQL queries (",[18,534,535],{},"POST \u002Fapi\u002Fdemo\u002Fgraphpg",[18,537,538],{},"POST \u002Fapi\u002Fdemo\u002Freset",") carrying Cloudflare Access service-token headers (",[18,541,542],{},"CF-Access-Client-Id",[18,544,545],{},"CF-Access-Client-Secret","). Even a nested clinical view with ",[18,548,549],{},"patient",[18,551,552],{},"encounter",[18,554,555],{},"observation"," rows compiles down to a single ",[18,558,559],{},"LATERAL"," SQL query on Postgres, so slow N+1 round trips across the tunnel do not happen.",[14,562,563],{},[104,564],{"alt":565,"src":566},"Request flow from Cloudflare Worker edge through Cloudflare Access Service Tokens and cloudflared tunnel into GraphPG 1.3.0, which compiles GraphQL into a single SQL statement against Postgres 18.","\u002Fimages\u002Fblog\u002Fsingle-query-compilation-poster.png",[65,568,570],{"id":569},"trade-offs-and-what-we-left-off-the-3-box","Trade-offs and what we left off the €3 box",[14,572,573,574,576,577,582],{},"Co-locating two workloads on 1 GB of RAM is not suitable for multi-gigabyte reporting workloads or strict compliance isolation where tenants cannot share an OS kernel or database cluster. If an API requires heavy analytical sorts or zero-downtime replication, managed PostgreSQL (such as UpCloud Managed Databases or Neon) and separate nodes remain the safer default. We also skipped local backups in ",[18,575,20],{}," intentionally because ",[23,578,581],{"href":579,"rel":580},"https:\u002F\u002Finnovi.pro\u002Fblog\u002Fzero-trust-demo-environments-cloudflare-upcloud-graphpg",[27],"the Innovi Pro zero-trust demo blueprint"," treats the whole machine as disposable and falls back inside each Cloudflare Worker when Pulumi destroys the VM.",[14,584,585,586,589,590,592],{},"Notice also where verification currently stops: I generated the Drizzle migrations, validated the Compose configuration and all four ",[18,587,588],{},"graphpg.yaml"," files locally, and built both Nuxt Cloudflare Worker frontends cleanly with the fallback endpoints wired in. Because we only bring up this demo VM during live sessions, the container heap caps shown here reflect Compose ",[18,591,127],{}," bounds rather than a long-running UpCloud soak test.",[14,594,595,596,598,599,604],{},"What else can you do once this pattern is in your repo? You can point the same ",[18,597,40],{}," binary at your staging schema alongside an existing REST API, or move DNS between ephemeral VPS instances without ever opening port 5432 or SSH to the public internet. If you need help auditing an oversize Postgres and API footprint, reach out through ",[23,600,603],{"href":601,"rel":602},"https:\u002F\u002Finnovi.pro\u002F#contact",[27],"Innovi Pro"," for an architecture review.",[606,607,608],"style",{},"html pre.shiki code .sPWt5, html code.shiki .sPWt5{--shiki-default:#7EE787}html pre.shiki code .sZEs4, html code.shiki .sZEs4{--shiki-default:#E6EDF3}html pre.shiki code .s9uIt, html code.shiki .s9uIt{--shiki-default:#A5D6FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":282,"searchDepth":299,"depth":299,"links":610},[611,612,613,614],{"id":67,"depth":299,"text":68},{"id":110,"depth":299,"text":111},{"id":486,"depth":299,"text":487},{"id":569,"depth":299,"text":570},"\u002Fimages\u002Fcovers\u002Frunning-two-graphpg-apis-on-a-3-dollar-vps.png","2026-11-14","How a 1 GB UpCloud server hosts two PostgreSQL 18 demo databases and two GraphPG 1.3.0 instances behind a Cloudflare Tunnel without overflowing RAM.","md",{"canonical_url":620},"https:\u002F\u002Fmihai.ltd\u002Fblog\u002Frunning-two-graphpg-apis-on-a-3-dollar-vps\u002F",true,"\u002Fblog\u002Frunning-two-graphpg-apis-on-a-3-dollar-vps",{"title":5,"description":617},"blog\u002Frunning-two-graphpg-apis-on-a-3-dollar-vps",[167,626,627,628,629,40],"graphql","rust","upcloud","cloudflare","blog_post","Z6zh3bNBccN8MWjdJ1dlnq8vZLZFo2H5fSznAW7Jlu8",null,1794689440868]