[Glass] rest api returning large result

Otto Behrens otto at finworks.biz
Thu May 16 22:09:34 PDT 2024


We are running into a performance problem where our API returns about 70MB
json content. We run a nginx web server which connects to a WAGsZincAdaptor
that we start in a topaz session. Do you perhaps have the same kind of
setup and can you please give me some advice on this?

We found that converting objects to json (using Object >> asJson from
Seaside-JSON-Core) was not performing great, but was eating loads of memory
because of WABuilder >> render:. This is not the issue and we improved this
a bit (by eliminating String streamContents: and streaming more directly).

The problem seems to be that after producing the json content, transmitting
the response takes a long time.

As an experiment, I read a 16MB file from disk and returned that as the
result of an API call to eliminate all json producing code. I used curl as
a client on the same machine as the nginx server, stone and the topaz
session and it takes 26 seconds. This eliminates most overhead (no network

The stack below is what I see most of the time:

1  SocketStream >> nextPutAll:  @natCode+0x4d  [GsNMethod 169113089]
              FP: 0x7f2c0fee9930=StackLimit[-218] , callerFP:
  arg 1:0x7f2bee7f0de0 (cls:103425 ByteArray size:16384)
  rcvr: 0x7f2bff68f670 (cls:144280577 SocketStream size:12)
2  ZnBivalentWriteStream >> next:putAll:startingAt:  @natCode+0x2cf
 [GsNMethod 158727169]
              FP: 0x7f2c0fee9960=StackLimit[-212] , callerFP:
  arg 3:69337098 (SmallInteger 8667137)
  arg 2:0x7f2c0064fe50 (cls:74753 String size:16627226)'(large_or_fwd (size
  arg 1:131074 (SmallInteger 16384)
  rcvr: 0x7f2c00675370 (cls:145086465 ZnBivalentWriteStream size:2)
3  ZnUtils class >> nextPutAll:on:  @natCode+0x421  [GsNMethod 175369473]
              FP: 0x7f2c0fee99b0=StackLimit[-202] , callerFP:
  arg 2:0x7f2c00675370 (cls:145086465 ZnBivalentWriteStream size:2)
  arg 1:0x7f2c0064fe50 (cls:74753 String size:16627226)'(large_or_fwd (size
  rcvr: 0x7f2c0c335750 oid:143053313 (cls:143054593 ZnUtils class size:19)
4  ZnByteArrayEntity >> writeOn:  @natCode+0xdb  [GsNMethod 269993473]
              FP: 0x7f2c0fee99e0=StackLimit[-196] , callerFP:
  arg 1:0x7f2c00675370 (cls:145086465 ZnBivalentWriteStream size:2)
  rcvr: 0x7f2c00651f00 (cls:145996545 ZnByteArrayEntity size:3)
5  ZnEntityWriter >> writeEntity:  @natCode+0x382  [GsNMethod 269988609]
              FP: 0x7f2c0fee9a30=StackLimit[-186] , callerFP:
  arg 1:0x7f2c00651f00 (cls:145996545 ZnByteArrayEntity size:3)
  rcvr: 0x7f2c00675398 (cls:145876737 ZnEntityWriter size:2)
6  ZnMessage >> writeOn:  @natCode+0x295  [GsNMethod 158696193]
              FP: 0x7f2c0fee9a60=StackLimit[-180] , callerFP:
  arg 1:0x7f2c00675370 (cls:145086465 ZnBivalentWriteStream size:2)
  rcvr: 0x7f2c0064fe20 (cls:145901313 ZnResponse size:3)
7  ZnResponse >> writeOn:  @natCode+0x1f0  [GsNMethod 155024025857]
              FP: 0x7f2c0fee9a90=StackLimit[-174] , callerFP:
  arg 1:0x7f2bff68f670 (cls:144280577 SocketStream size:12)
  rcvr: 0x7f2c0064fe20 (cls:145901313 ZnResponse size:3)
8  ZnSingleThreadedServer >> writeResponse:on:  @natCode+0xa3  [GsNMethod
              FP: 0x7f2c0fee9ab8=StackLimit[-169] , callerFP:
  arg 2:0x7f2bff68f670 (cls:144280577 SocketStream size:12)
  arg 1:0x7f2c0064fe20 (cls:145901313 ZnResponse size:3)
  rcvr: 0x7f2bff5de528 oid:4763064833 (cls:144532225
ZnManagingMultiThreadedServer size:9)

Kind regards

Otto Behrens

+27 82 809 2375
[image: FINWorks]
[image: FINWorks] <http://za.linkedin.com/in/waltherbehrens>

Disclaimer & Confidentiality Note: This email is intended solely for the
use of the individual or entity named above as it may contain information
that is confidential and privileged. If you are not the intended recipient,
be advised that any dissemination, distribution or copying of this email is
strictly prohibited. FINWorks cannot be held liable by any person other
than the addressee in respect of any opinions, conclusions, advice or other
information contained in this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/archives/glass/attachments/20240517/e8a78b5c/attachment.htm>

More information about the Glass mailing list