# Racket script or executable as CGI

**URL:** <https://racket.discourse.group/t/racket-script-or-executable-as-cgi/4167>\
**Category:** Questions & Answers\
**Created:** [March 26, 2026, 3:51am UTC](https://racket.discourse.group/t/racket-script-or-executable-as-cgi/4167 "2026-03-26T03:51:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gritty](https://avatars.discourse-cdn.com/v4/letter/g/74df32/32.png) [@gritty](https://racket.discourse.group/u/gritty)\
**Post date:** [March 26, 2026, 3:51am UTC](https://racket.discourse.group/t/racket-script-or-executable-as-cgi/4167/1 "2026-03-26T03:51:18Z")

</div>

I am a long-time citizen of the [Gemini Protocol](https://www.nicfab.eu/en/posts/gemini-protocol/) and in that arena we use CGI and SCGI to serve dynamic content (_gasp_ I know, but we embrace it - check the link). I created a SCGI server in Racket to serve a basic client/server text-based dice game in Gemini (also written in Racket), but now I wanted to use Racket for CGI for a different project (comment system). For reference, we're talking maybe dozens of users here, not hundreds or thousands. Here are my questions:

- Compiling racket programs create rather large executables that are not ideal for repetitive execution via CGI (hence I made a SCGI server). Can Racket scripts fill this role, or are they slow in this regard?
- If the answer to the above is "no" should I pick a different language for efficient CGI scripts? I've used Go in the past because I can get the file size down, but I'd like to stick with Racket.

Any suggestions are appreciated.

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [March 26, 2026, 9:02am UTC](https://racket.discourse.group/t/racket-script-or-executable-as-cgi/4167/2 "2026-03-26T09:02:44Z")

</div>

I think, the usual advice is to (listed in order of effort):

- make sure the program is compiled [1]
- try the demodularizer [2]

If the startup latency is still too high, you can

- use a daemon

Finally, you can experiment with Zuo. [3]  
Zuo is a dialect of Racket tailor-made for cross-platform scripts.  
You can compile your Zuo program into a single C-file.

[1] `raco make your-file.rkt`  
[2] [raco demodularize](https://docs.racket-lang.org/raco/demod.html)  
[3] [Zuo: A Tiny Racket for Scripting](https://docs.racket-lang.org/zuo/index.html)

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [March 26, 2026, 5:05pm UTC](https://racket.discourse.group/t/racket-script-or-executable-as-cgi/4167/3 "2026-03-26T17:05:03Z")

</div>

Let me add a bullet to Jens’ advice:

Write your code in #lang racket/base, and `require` just those libraries that are needed.  
This will reduce start-up time.

Otherwise compiled Racket code should be fast enough to serve a couple of hundred users.

---

<div class="post-metadata">

**Author:** ![lukem12345](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/lukem12345/32/2619_2.png) [@lukem12345](https://racket.discourse.group/u/lukem12345)\
**Post date:** [March 30, 2026, 11:36pm UTC](https://racket.discourse.group/t/racket-script-or-executable-as-cgi/4167/4 "2026-03-30T23:36:17Z")

</div>

I've used `#lang racket/base` for making a simple CGI site with `net/cgi` and haven't experienced any performance issues (although I should emphasize how simple the site is.) The largest issue with respect to latency was when I was outputting xml (`output-xml`) on individual HTML components, instead of combining all components and outputting xml just once.

> **[GitHub - lukem12345/DecapodesLeaderBoard: DecapodesLeaderBoard is a simple CGI site where we...](https://github.com/lukem12345/DecapodesLeaderBoard)**
>
> DecapodesLeaderBoard is a simple CGI site where we can keep track of example Decapodes implementations.

> **[Decapodes Leaderboard](https://cise.ufl.edu/~luke.morris/dlb.cgi)**
