Would refactoring mod_harbour from CGI to module mode significantly improve performance?
The summarized answer was quite clear:
---
🧠 Root cause
The 400–500 ms are not caused by Harbour code, but by the CGI model itself:
- new process per request
- runtime + modules loaded every time
- PRG possibly compiled at runtime
---
💡 Suggested approach
- use
SetHandler harbour instead ofcgi-bin - runtime stays in memory (no process startup per request)
- optional: precompile
.prg →.hrb
---
⚡ Expected impact
- current: 400–500 ms
- after change: 5–20 ms
---
🔧 Effort
Surprisingly manageable:
- adjust Apache configuration
- change URLs (
/cgi-bin/... → direct/file.prg ) - code mostly unchanged
- optional cleanup (remove CGI-specific parts)
---
⚠️ One important difference
With mod_harbour, the environment becomes persistent:
- memory is not reset between requests
- global/static variables remain
This needs to be considered (unlike CGI where everything is reset each time).
---
🤔 Question to the community
Has anyone already switched from CGI to mod_harbour (module mode)?
- What response times did you observe?
- Any issues with persistent state / memory?
- Is anyone using
.hrb instead of.prg in production?
---
To me, this looks like a large performance gain with relatively low effort, before considering bigger architectural changes (like microservices).
Curious to hear your experiences