Would refactoring mod_harbour from CGI to module mode significantly improve performance?
Can the 500 ms per request in a mod_harbour CGI setup be eliminated “easily”?
And if so – how much effort would it take?
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
Move away from CGI → use mod_harbour as an Apache module
- use
SetHandler harbourinstead 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)
Estimated effort: hours rather than days
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
.hrbinstead of.prgin 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