You have those options:
1. you use $ZF(-1) or $ZF(100) to execute a command line from the OS
2. To use embedded python (if your version of IRIS has it) where you can use os. getpid() :
>Write $system.Python.Shell()
Python 3.9.5 (default, Jul  8 2023, 00:24:17) [MSC v.1927 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.
>>> import os
>>> print(os. getpid())
16232

I would try to:
1. check if there is a header for "Content-Length" (the client is setting this)
2. As the %CSP.Request is a stream you might try to check it's "size" property
3. Find the global(s) that are storing this request (not sure which, maybe ^%csp.session or some CacheTemp.csp* with the sessionID - would be a bit complex since its not documented.

To increase your performance there are many factors and test that need to be done in order to take the best action (and approach). Some of them are:

1. Its highly recommended to identify the bottleneck before doing any action.
2. Hardware and infrastructure: Start by monitoring your infrastructure and hardware (network, memory, CPU) to check if there are any bottlenecks. Use task manager (or similar on Linux) to see if one or more disks are exhausted (100% active) - maybe splitting the databases and/or other Cache components (e.g. journals, WIJ, IRISTEMP etc.) between different disks might solve that issue. check if server has enough memory. How many processes are there? is the O/S using swap files when memory is low?
2. Check IRIS (or Cache) related issues: memory usage (are you allocation enough global and routine buffers) heap etc. - are there any errors in console.log that might show any potential issues?
3. Some production related things:
a. Can you run your process in parallel (pool size > 1) - maybe the bottleneck is there
b. Code - is your code optimized - use MONLBL to check the most "overwhelmed" places in your code
c. Journaling & mirroring might slow things if a lot of "temporary data" is journaled and mirrored

This is just the tip of the iceberg... there are many more things that can be done.
If you feel lost, I recommend that you open a WRC to get specific (your system related) help.  

Very nice article. Its exiting to see that Intersystems developers are taking advantage of the (great) Embedded Python feature in IRIS.

If you want to see a "real life" use case (we are using it for more than 2 years in our production environment), check this article: IRIS Embedded Python with Azure Service Bus (ASB) use case | InterSystems
(it also won the 1st place in an Intersystems article competition in 2022)