DEV Community

Blck Alpaca
Blck Alpaca

Posted on Originally published at blckalpaca.at

SearXNG + Crawl4AI: Why We Fired SerpAPI and Built Our Own Stack

SearXNG + Crawl4AI: Why We Fired SerpAPI and Built Our Own Stack

The $920 invoice that arrived in March 2024 wasn't shocking—it was expected. We'd been running SerpAPI and Firecrawl for months, powering four n8n workflows that collected research data for content briefs and market analysis. The payment cleared automatically. Then someone asked: "Why are we paying for this when we could host it ourselves?"

Three weeks later, both SerpAPI and Firecrawl were gone. In their place: SearXNG and Crawl4AI running on our own infrastructure. Monthly cost for these services: zero. The insight wasn't about ideology—it was economics. When you make the same API call 40,000 times monthly, self-hosting stops being a technical experiment and becomes a business decision.

This is the engineering story behind that transition: what worked, what broke, and why we'd do it again despite the maintenance overhead.

The Architecture: Two Tools, Sequential Execution

Our research stack consists of two components working in sequence. SearXNG handles discovery, Crawl4AI handles extraction. Both run on dedicated infrastructure accessible only to internal workflows, eliminating external API dependencies for 95% of our research operations.

SearXNG serves as our meta-search layer. It aggregates results from Google, Bing, DuckDuckGo, and other engines without requiring separate API keys for each provider. We operate a single instance on a dedicated server, configured to accept requests exclusively from our n8n workflow environment. Search queries originate from either manual triggers or scheduled runs, depending on the workflow type.

Crawl4AI handles structured extraction. After SearXNG returns URLs, Crawl4AI scrapes content, extracts metadata, and converts pages to clean Markdown. For structured data extraction (prices, contact information, product specifications), we pipe Markdown output through LLM-based parsing. The library runs in a Python container exposed via HTTP API, which our n8n workflows call directly.

The four workflows built on this stack serve distinct purposes:

  • Topic research for editorial planning: identifying trending subjects and content gaps
  • Competitive analysis: tracking which keywords competitors rank for and content strategies they deploy
  • Lead enrichment: gathering publicly available information about target companies
  • Trend monitoring: analyzing discussions in industry publications and forums

Each workflow follows the same pattern: query SearXNG, filter results by relevance score, send top 10-15 URLs to Crawl4AI, store extracted content in PostgreSQL for downstream processing. The database serves as source material for content briefs, market reports, and client deliverables.

Why SerpAPI Made Sense—Until It Didn't

SerpAPI wasn't a bad choice. The API was stable, results were consistent, documentation was thorough. For small-scale operations, it remains the right call. But our usage pattern changed the equation.

The volume problem became obvious in Q1 2024. We were executing 35,000 to 42,000 search requests monthly. At SerpAPI's pricing ($50-75 per 1,000 queries depending on plan tier), that translated to $400-600 monthly. Add Firecrawl's per-page scraping costs ($0.01-0.03 per page), and we were spending $800-900 monthly on research infrastructure alone.

SearXNG costs us $80 monthly for dedicated server infrastructure that also hosts other internal services. Setup required approximately 20 engineering hours. Break-even occurred after six weeks. Since then, we've saved $600-800 monthly—but the financial calculation isn't the complete story.

Control became the primary strategic advantage. With self-hosted infrastructure, we can execute unlimited queries without rate limit negotiations or pricing changes. For GDPR-sensitive research—particularly when collecting market data for client projects—keeping all data on our infrastructure eliminates third-party data processing agreements. When a client in the DACH region asks where their competitive intelligence data flows, we can answer: "Nowhere. It stays on our servers."

The Google Custom Search API would have been cheaper than SerpAPI ($5 per 1,000 queries), but it imposes a 10-result limit per request and lacks the granular date and language filtering our workflows require. SearXNG aggregates multiple sources, returns 50+ results per query, and runs entirely on infrastructure we control. No vendor lock-in. No surprise deprecations. No external dependencies for core research operations.

The Maintenance Reality: What SaaS Abstracts Away

Self-hosting isn't free—it shifts costs from subscription fees to engineering time. The first two months revealed what SaaS providers handle invisibly.

IP blocking became our first operational issue. Google and Bing temporarily blocked our server IP three times in the first eight weeks because our request pattern looked suspicious. Solution: IP rotation across multiple egress points plus rate limiting at the application layer. SerpAPI would have handled this transparently. We had to build it.

Error handling required custom implementation. Firecrawl gracefully handled timeouts, returning partial results when pages loaded slowly. It automatically rotated through user agents and proxy configurations when encountering bot detection. Crawl4AI does none of this by default. When a page fails to load, you get an empty string or HTTP 500. We built retry logic, timeout handling, and fallback strategies ourselves—two days of engineering work that a SaaS product would have included.

The production deployment exposed our memory management oversight. We'd tested with 500-1,000 URLs successfully. Then we ran the first production batch: 8,000 URLs over four hours. After two hours, the Crawl4AI container crashed. Out of memory.

Playwright spawns a browser process for each URL. At 50 concurrent requests, memory consumption hit 16GB and killed the container. The fix was straightforward: reduce concurrency to 10 parallel requests, deploy a second container for load distribution. But this illustrates the fundamental self-hosting trade-off: with SaaS, infrastructure problems are the vendor's responsibility. With self-hosted systems, they're yours.

We lost two hours of processing time and generated a dozen urgent Slack messages. We fixed it, documented it, and moved on. But it's worth acknowledging: this wouldn't have happened with Firecrawl.

Crawl4AI vs. Firecrawl: The Engineering Trade-Off

Firecrawl was our scraping service before Crawl4AI. Integration was simple, reliability was high, but costs scaled linearly with usage. At $0.01-0.03 per scraped page, processing 15,000-20,000 pages monthly cost $150-600 depending on complexity.

Crawl4AI is open source, runs locally, and costs only compute time. Built in Python, it uses Playwright for JavaScript rendering and offers LLM integration for structured data extraction. We deployed it as a FastAPI service that n8n workflows call via HTTP. Each request includes the URL and parameters (timeout duration, JavaScript rendering requirements, output format preference). The response returns either Markdown or JSON with extracted fields.

For most use cases, Markdown output suffices. When we need structured data—product prices, contact information, technical specifications—we send Markdown to an LLM that extracts specific fields. This two-stage approach (Crawl4AI for content, LLM for structure) proved more reliable than trying to extract structure during the scraping phase.

Result quality from Crawl4AI exceeds Firecrawl's Markdown output. The content is cleaner, better formatted, and preserves semantic structure more accurately. But Crawl4AI requires more manual intervention for edge cases. Firecrawl handled bot detection, CAPTCHA challenges, and dynamic content loading automatically. With Crawl4AI, we implement these ourselves or accept occasional failures.

The economic calculation is straightforward: we traded $150-600 monthly in scraping costs for 40 hours of initial engineering work plus ongoing maintenance. At our current scale, that trade makes sense. For organizations processing fewer than 5,000 pages monthly, Firecrawl's convenience likely outweighs the cost savings.

What We're Not Measuring Yet (And Why That's Acceptable)

We don't have comprehensive metrics for this pipeline. No latency dashboards, no systematic success rate tracking, no cost-per-query analysis. The system has been running for eight weeks, and our focus has been operational stability, not quantitative optimization.

Quantitative evaluation is planned for Q3 2024 when we'll have sufficient data for meaningful comparisons. Until then, we're tracking qualitative indicators: result relevance, content extraction quality, workflow completion rates, and incident frequency.

What we can say qualitatively:

  • SearXNG result quality matches or exceeds SerpAPI because we aggregate multiple sources rather than relying on a single provider's index
  • Crawl4AI produces cleaner Markdown than Firecrawl but requires more robust error handling
  • System reliability is acceptable: 97% of scheduled workflows complete without manual intervention
  • Cost savings are substantial: $600-800 monthly reduction in external API expenses

This isn't rigorous analysis—it's operational observation. But for an eight-week-old system still in active development, it's sufficient validation. We're solving the right problem, the economics work, and we have control over the entire stack.

When Self-Hosting Makes Sense (And When It Doesn't)

Self-hosting isn't universally superior to SaaS. The decision depends on usage patterns, team capabilities, and strategic priorities.

Self-hosted infrastructure becomes economically viable when:

  • Monthly API costs exceed $300-500 consistently
  • Usage volume is stable and predictable (30,000+ queries monthly)
  • Your team has engineering capacity for server maintenance
  • Data sovereignty or GDPR compliance requires keeping data on your infrastructure
  • You need customization that SaaS providers don't offer

SaaS remains the better choice when:

  • Usage is variable or unpredictable (under 10,000 queries monthly)
  • You lack in-house infrastructure management capabilities
  • Time-to-market is more valuable than long-term cost optimization
  • Your team is small and engineering time is the constraint

At Blck Alpaca, we operate research pipelines intensively for internal content production and client projects. Our usage is consistent, our team can manage infrastructure, and GDPR compliance is a competitive advantage in the DACH market. The self-hosted approach aligns with our operational model.

The critical insight: you're trading monthly API costs for one-time engineering investment plus ongoing maintenance burden. That trade makes economic sense at scale. It doesn't make sense for everyone.

If we were building this system again, we'd implement concurrency limits and comprehensive error handling from day one rather than discovering these requirements in production. We'd also start collecting metrics earlier—not because we need them immediately, but because retrofitting observability is more difficult than building it initially.

The Real Lesson: Infrastructure Decisions Are Context-Dependent

The decision to replace SerpAPI and Firecrawl with SearXNG and Crawl4AI wasn't about proving self-hosting superiority. It was about recognizing when our usage pattern crossed the threshold where economics favored building over buying.

For organizations running similar research operations at scale, this architecture offers:

  • Elimination of variable API costs that scale with usage
  • Complete data control for GDPR compliance and client confidentiality
  • Customization possibilities that SaaS platforms don't support
  • Independence from vendor pricing changes and API deprecations

The trade-offs are real and non-trivial:

  • Initial engineering investment (40-60 hours for complete implementation)
  • Ongoing maintenance responsibility (approximately 4-6 hours monthly)
  • Infrastructure costs (server hosting, monitoring, backup)
  • Operational complexity (error handling, scaling, incident response)

We made this trade knowingly. The economics work for our use case. The system is stable. We have control over our research infrastructure. And we're saving $7,000-10,000 annually that previously went to API subscriptions.

Would we recommend this approach universally? No. Would we do it again for our specific situation? Absolutely.

Ready to optimize your AI research infrastructure or explore Generative Engine Optimization strategies for your content operations? Blck Alpaca specializes in building scalable, cost-effective AI systems for DACH market leaders. Visit blckalpaca.at to discuss how we can help you make smarter infrastructure decisions.


Originally published by Blck Alpaca - Data-Driven Marketing Agency from Vienna, Austria.

Top comments (0)