WebGS is a framework for building the back-end for modern web applications in GemStone/S 64 Bit Smalltalk. It provides a basic server and can respond to HTTP requests with Smalltalk-generated strings. While these strings can be HTML, in today's environment it is more common that they will be JSON.
- Set environment variables for your GemStone system.
export GEMSTONE=/path/to/gemstoneexport PATH=$GEMSTONE/bin
- Create
.topaziniin this directory or in your home directory.set user DataCurator pass swordfish gems gs64stone
- Optional: Run
setUnicodeMode.shto use the modern character comparison mode (recommended if this is a new install). - Run
install.shto install WebGS into your GemStone/S system.
The typical use is to subclass WebApp and override appropriate methods. To see how this works, take a look at Sample.gs. You can run the application from a Topaz prompt (see sample.sh) or from an IDE (such as Jade) using Sample runHttp. If you have breakpoints, halts, or errors in your code, then the server will stop and you can debug the code (or just step through it to see how it works). To test the server, access it from a web browser (http://localhost:8888) or from a Linux or macOS shell:
curl http://localhost:8888/stone.gs
curl --header "Content-Type: application/json" \
--request POST \
--data '{"x":3,"y":5}' \
http://localhost:8888/add.gs \
&& echo
curl http://localhost:8888/index.htmlOf course, simple GET requests can be submitted from a browser and Postman is a great tool for working with web servers.
Sample.gs also has a demo of WebSockets. Please keep in mind that all your WebSocket connections on this host/port will be sharing the same gem and each connection will stay alive until it is dropped by the client. This may affect performance (depending on how much activity each connection requires) and it may affect behavior (think very carefully about changes to persistent objects and transactions!).
WebGS includes a set of tests written in Dart.
./runGCI.sh # in one shelldart tests/jade_server_test.dart # in another shellThe tests also provides an example of how to interact with WebGS from a client application.
Recent tests have been run with Locust. On a 3.7.5 GemStone server (with round-trip ping time of 15ms) using a single gem (no load balancing) the following were observed for the /add.gs?x=1&y=2 request:
| Protocol | Median (ms) | 95%ile (ms) | 99%ile (ms) | Average (ms) | Min (ms) | Max (ms) | RPS |
|---|---|---|---|---|---|---|---|
| http | 32 | 53 | 68 | 35 | 2 | 1051 | 2900 |
| https | 190 | 250 | 280 | 191 | 115 | 322 | 25 |
At present there is a serious performance problem with HTTPS. This is being investigated as GemTalk issue #51782.
Note that for trivial operations, the sync server is faster (no load balancing overhead), but for operations that take non-trivial CPU time, the async server shows significant benefits.