We indexed 10,543 hosting plans. Here's how we made prices comparable across 20 currencies.

2026-12-02来源 dev.toEnglish
We indexed 10,543 hosting plans. Here's how we made prices comparable across 20 currencies.

When we started building LikeHost, a free comparison table for hosting plans, we assumed the hard part would be collecting data from 1,914 providers.

It wasn't.

The hard part is that a "cheap VPS" is priced in USD in one country, JPY in another, EUR in a third, and VND somewhere else. Sort those rows by the raw price column and ¥1,200 lands next to $3.50, producing complete nonsense. Worse: someone filtering "under $10/month" silently misses a ¥980 plan that actually costs about $6.50.

Here's how we fixed it without hiding anyone's native currency.

Keep the original price, normalize only inside the query

We store every price exactly as the provider publishes it: amount plus currency. The UI always renders the original — users in Japan see ¥, users in Germany see €. We never show a converted number to the visitor; showing "$6.50" on a Japanese provider's row is a trust killer.

For filtering and sorting, we derive a USD value inside SQL, so there is no denormalized column that can drift out of sync with the data:

-- generated by sql_usd(amount_expr, currency_expr) (CASE currency WHEN 'USD' THEN 1.0000000000 WHEN 'EUR' THEN 1.0800000000 WHEN 'GBP' THEN 1.2700000000 WHEN 'JPY' THEN 0.0066666667 WHEN 'INR' THEN 0.0119047619 WHEN 'VND' THEN 0.0000393701 ... ELSE 1.0 END) * amount 

The same expression is reused in both the WHERE clause (max price) and the ORDER BY (cheapest / most expensive). One helper builds it from a rate table:

USD_RATES = {"USD": 1.0, "EUR": 1.08, "GBP": 1.27, "JPY": 1 / 150.0, "BRL": 1 / 5.4, "AUD": 0.66, "CZK": 1 / 23.0, "PLN": 1 / 4.0, "SGD": 0.75, "HKD": 0.128, "INR": 1 / 84.0, "CHF": 1.13, "IDR": 1 / 16000.0, "MXN": 1 / 17.0, "VND": 1 / 25400.0, "ZAR": 1 / 18.0, "TRY": 1 / 34.0, "ILS": 3.7, "CLP": 1 / 950.0, "PEN": 1 / 3.75} def sql_usd(amount_expr: str, currency_expr: str) -> str: """SQL expression converting a price column to USD via a CASE table.""" cases = " ".join( f"WHEN '{code}' THEN {rate:.10f}" for code, rate in USD_RATES.items() ) return f"(CASE {currency_expr} {cases} ELSE 1.0 END) * {amount_expr}" 

Two rules we learned the hard way:

  1. Never convert on write. Rates move. If you persist a usd_price column, your entire table is wrong the next day, and re-crawling every provider to fix it is expensive.
  2. Never convert in the template. It's tempting to do price * rate in the render layer, but then filtering and sorting need the same logic duplicated in Python — and the two will eventually disagree. Put it in the query, once.

Homepage: filtering by specs and price

20 languages means 20 different titles

A comparison site lives or dies on long-tail search traffic, so every product page needs a proper title in its own language — including the product type. "VPS", "云服务器", "専用サーバー" and "GPU-Server" are not the same word, and stuffing the English label into a Japanese <h1> looks broken to both users and crawlers.

We keep a per-locale label table and build the title from parts:

title_core = f"{product['plan_name']} {type_label} ({product['provider_name']})" 

Then canonical + hreflang + x-default, RTL direction for Arabic and Hebrew, and a sitemap split per language so no single file grows past a few thousand URLs. The sitemaps are generated on request — a new crawl batch shows up in them without a restart or a deploy.

The same catalog rendered in Japanese

The boring parts that mattered most

  • Pseudo-static pagination — /de/vps/page/3/ instead of ?page=3, with a 301 for the trailing slash and a real 404 for out-of-range pages, so crawlers don't index an infinite tail of empty pages.
  • JSON-LD with the localized category, so the plan type is machine-readable rather than just visual.
  • Edge caching with a versioned cache key, so a deploy invalidates cached HTML without touching the database.
  • Outbound links through JS only, never a raw <a href> to an external site. This was our own constraint, and it later turned out to disqualify quite a few launch directories that require you to embed their badge.

A product detail page with full specs

Where it ended up

LikeHost now covers 10,543 plans from 1,914 providers, filterable by vCPU, RAM, storage, region and monthly price, in 20 languages, with no sign-up. It's a single Python-stdlib HTTP server in front of SQLite — no framework, no build step, no JS bundle.

The provider index

If you're building something similar: normalize currencies in the query, never on write, never in the UI. Everything else is just tables.

How do you handle rate updates? We're still pinned to a static table and debating a daily refresh versus a monthly snapshot — I'd love to hear how others deal with this.

原文:https://www.a8q9.cn/en/article/we-indexed-10-543-hosting-plans-here-s-how-we-made-prices-comparable-across-20-c-6ec54b.html

相关文章