Performance & API suggestions for large‑scale (100 + participant) experiments

62 views
Skip to first unread message

Anton Schmidt

unread,
Jun 27, 2025, 5:18:48 PM6/27/25
to LIONESS Lab help and discussion
Dear LIONESS Lab team and community,

We are preparing to run an experiment with 100 + concurrent participants and would appreciate your advice on server‑side performance and API best practices.

1  Bulk read/write operations

During a single participant’s path through the experiment we call getValue and setValue many times. To keep round‑trip latency low we would love to:
  • Get multiple values in one request – e.g. getValues(["key1","key2","key3"]) returning a JSON object.
  • Set multiple values in one request – e.g. setValues({key1:v1, key2:v2, …}).
  • Option B: allow setValue calls to be buffered temporarily on the server (cache=true), and expose a lightweight flush() endpoint that writes the buffer to the database at the end of each stage.

Such a batch/flush option would reduce HTTP traffic dramatically and avoid many tiny writes under heavy load.

2  Unexpected traffic from _beginParticipant.php

We noticed that every hit to …/_beginParticipant.php automatically triggers two getValue and one setValue calls before any of our own screen code runs. With ≥ 50 simultaneous log‑ins these extra calls alone saturate our PHP/MySQL server, leading to time‑outs.

  • Can this behavior be batched?

3  Cookie header bloat

When we launch many bots in parallel from the same browser for load‑testing, the request header grows because every cookie ever set by the site is sent back on every request. Eventually the header exceeds the server limit and Apache returns 400 Bad Request.

  • Would you consider setting per‑participant cookies with the Path attribute (e.g. /exp/12345/) so that irrelevant cookies are not attached to every request?
  • Alternatively, could the session identifier be moved to localStorage and sent explicitly as a query parameter or custom header?

4  Open Source Contributions

If the platform code were hosted on GitHub we (and surely others) would be happy to open a pull request that implements the bulk‑read/bulk‑write API outlined above, plus the cookie optimisation.
Benefits of open‑sourcing LIONESS Lab:

  • Faster bug‑fixes and new features through community PRs
  • Transparent security review and reproducibility (important for academic work)
  • Easier integration into institutional DevOps pipelines (CI/CD, automated tests)
  • A plugin ecosystem (custom screen types, matchmaking rules etc.) could flourish without increasing your maintenance burden

Please let us know whether the core code is likely to be released, or if there is another preferred way for external contributors to help.

Many thanks for your excellent work on LIONESS Lab and for any guidance you can provide.

Best regards,
Anton Schmidt
Message has been deleted

Anton Schmidt

unread,
Jun 28, 2025, 4:39:52 PM6/28/25
to LIONESS Lab help and discussion
Addendum to: 2  Unexpected traffic from _beginParticipant.php.

We are running an asynchronous experiment without groups.
We discovered that clientConnected.php is being sent every 3 seconds, even in later stages of our experiment, due to that fact.
Would it be possible to introduce some kind of checkbox in the frontend, to increase the interval this checks are made? e.g. to every 60 seconds for tests without groups.

For now, we manually increased the timeout to 30 seconds in the keepConnected.js file.


Code Patch available

We went ahead and created the batchGetValues and batchSetValues functions and would love to see them implemented on your side, to benefit all. 
Since we cannot upload a .zip file here, these pastebins with code adjustments:

jsLibrary.js:

batchSetValues.php
https://pastebin.com/cCzmUWzh

Usage example:

// get values from server and assign them to js variables
var {a1_counter, a2_counter, a3_counter, a4_counter, a5_counter, a6_counter}= batchGetValues([
'a1_counter',
'a2_counter',
'a3_counter',
]);


// set multiple values
batchSetValues({
'a1_counter': a1_counter+1,
'a2_counter': a2_counter+1,
'a3_counter': a3_counter+1,
})


Request for batchRecords function

Another thing we would love to get is a batchRecords(['record1', 'record2']) function, which we cannot implement on our side, due to your processing of the column names into the setup_tables.sql upon compilation.

Best regards,
Anton Schmidt


Anton Schmidt

unread,
Jun 30, 2025, 1:13:18 PM6/30/25
to LIONESS Lab help and discussion
New batchGetValues.php, which can also handle complex requests like:


var {treatment, choice, History, HistOther}= batchGetValues([
    {tableName: "decisions", condition: `playerNr=${playerNr} and period=${period}`, varNames:['treatment', 'choice']},
    {tableName: 'decisions', condition: `playerNr=${playerNr} and period=${period-1}`, varNames:['History', 'HistOther']}]
);
is available here: 
https://pastebin.com/AjEXZJUS
Reply all
Reply to author
Forward
0 new messages