Jibri recording starts very slowly

I am using jibri 8.0-116-gca0c772-1 and google chrome 97.0.4692.99
but recording start takes around 5~6 seconds.
can we optimize the start time around 2~3 seconds?

Here is the jibri logs for recording start.
it’s from clicking recrod button on meet UI until ‘REC’ indicator show up.

2022-03-03 11:29:33.922 INFO: [48] XmppApi.handleJibriIq#171: Received JibriIq <iq xmlns='jabber:client' to='jibri@auth.test.heyjoe.io/ORVLj3sg' from='jibribrewery@internal.auth.test.heyjoe.io/focus' id='amlicmlAYXV0aC50ZXN0LmhleWpvZS5pby9PUlZMajNzZwBNRjEyRi0xMDYzMDE5AOHNDqEtPQqUGPuQkIMH3Ls=' type='set'><jibri xmlns='http://jitsi.org/protocol/jibri' action='start' recording_mode='file' room='1212121212@conference.test.heyjoe.io' session_id='smqehokzamlnhkkg' app_data='{"file_recording_metadata":{"share":false}}'/></iq> from environment [MucClient id=test.heyjoe.io hostname=test.heyjoe.io]
2022-03-03 11:29:33.923 INFO: [48] XmppApi.handleStartJibriIq#199: Received start request, starting service
2022-03-03 11:29:33.926 INFO: [48] XmppApi.handleStartService#304: Parsed call url info: CallUrlInfo(baseUrl=https://test.heyjoe.io, callName=1212121212, urlParams=[])
2022-03-03 11:29:33.927 INFO: [48] JibriManager.startFileRecording#138: Starting a file recording with params: FileRecordingRequestParams(callParams=CallParams(callUrlInfo=CallUrlInfo(baseUrl=https://test.heyjoe.io, callName=1212121212, urlParams=[]), email='', passcode=null, callStatsUsernameOverride=, displayName=), sessionId=smqehokzamlnhkkg, callLoginParams=XmppCredentials(domain=recorder.test.heyjoe.io, port=null, username=recorder, password=*****))
2022-03-03 11:29:33.927 FINE: [48] [session_id=smqehokzamlnhkkg] FfmpegCapturer.<init>#88: Detected os as OS: LINUX
2022-03-03 11:29:34.260 INFO: [48] org.openqa.selenium.remote.ProtocolHandshake.createSession: Detected dialect: OSS
2022-03-03 11:29:34.266 INFO: [48] [session_id=smqehokzamlnhkkg] FileRecordingJibriService.<init>#134: Writing recording to /tmp/recordings/smqehokzamlnhkkg, finalize script path /home/finalize_recording.sh
2022-03-03 11:29:34.266 FINE: [48] JibriStatsDClient.incrementCounter#38: Incrementing statsd counter: start:recording
2022-03-03 11:29:34.266 INFO: [48] JibriStatusManager$$special$$inlined$observable$1.afterChange#72: Busy status has changed: IDLE -> BUSY
2022-03-03 11:29:34.266 FINE: [48] WebhookClient$updateStatus$1.invokeSuspend#107: Updating 0 subscribers of status
2022-03-03 11:29:34.267 INFO: [48] XmppApi.updatePresence#144: Jibri reports its status is now JibriStatus(busyStatus=BUSY, health=OverallHealth(healthStatus=HEALTHY, details={})), publishing presence to connections
2022-03-03 11:29:34.269 INFO: [48] XmppApi.handleStartJibriIq#207: Sending 'pending' response to start IQ
2022-03-03 11:29:34.269 INFO: [86] AbstractPageObject.visit#32: Visiting url https://test.heyjoe.io
2022-03-03 11:29:35.324 INFO: [86] AbstractPageObject.visit#38: Waited 1.05s for driver to load page
2022-03-03 11:29:35.365 INFO: [86] AbstractPageObject.visit#32: Visiting url https://test.heyjoe.io/1212121212#config.iAmRecorder=true&config.externalConnectUrl=null&config.startWithAudioMuted=true&config.startWithVideoMuted=true&interfaceConfig.APP_NAME="Jibri"&config.analytics.disabled=true&config.p2p.enabled=false&config.prejoinPageEnabled=false&config.prejoinConfig.enabled=false&config.requireDisplayName=false
2022-03-03 11:29:36.232 INFO: [86] AbstractPageObject.visit#38: Waited 866ms for driver to load page
2022-03-03 11:29:36.251 FINE: [86] CallPage$visit$$inlined$measureTimedValue$lambda$1.apply#58: Not joined yet: Cannot read properties of undefined (reading 'isJoined')
2022-03-03 11:29:36.757 FINE: [86] CallPage$visit$$inlined$measureTimedValue$lambda$1.apply#58: Not joined yet: Cannot read properties of undefined (reading 'isJoined')
2022-03-03 11:29:37.269 FINE: [86] CallPage$visit$$inlined$measureTimedValue$lambda$1.apply#58: Not joined yet: Cannot read properties of undefined (reading 'isJoined')
2022-03-03 11:29:37.856 INFO: [86] CallPage.visit#71: Waited 1.62s to join the conference
2022-03-03 11:29:37.858 INFO: [86] [session_id=smqehokzamlnhkkg] EmptyCallStatusCheck.<init>#26: Starting empty call check with a timeout of PT30S
2022-03-03 11:29:37.903 INFO: [86] [session_id=smqehokzamlnhkkg] JibriSelenium.onSeleniumStateChange#215: Transitioning from state Starting up to Running
2022-03-03 11:29:37.911 INFO: [86] [session_id=smqehokzamlnhkkg] FileRecordingJibriService$start$1.invoke#167: Selenium joined the call, starting the capturer
2022-03-03 11:29:37.984 INFO: [86] [session_id=smqehokzamlnhkkg] JibriSubprocess.launch#42: Starting ffmpeg with command ffmpeg -y -v info -f x11grab -draw_mouse 0 -r 30 -s 1920x1080 -thread_queue_size 4096 -i :0.0+0,0 -f alsa -thread_queue_size 4096 -i plug:bsnoop -acodec aac -strict -2 -ar 44100 -b:a 128k -af aresample=async=1 -c:v libx264 -preset veryfast -profile:v main -level 3.1 -pix_fmt yuv420p -r 30 -crf 25 -g 60 -tune zerolatency -f mp4 /tmp/recordings/smqehokzamlnhkkg/1212121212_2022-03-03-11-29-34.mp4 ([ffmpeg, -y, -v, info, -f, x11grab, -draw_mouse, 0, -r, 30, -s, 1920x1080, -thread_queue_size, 4096, -i, :0.0+0,0, -f, alsa, -thread_queue_size, 4096, -i, plug:bsnoop, -acodec, aac, -strict, -2, -ar, 44100, -b:a, 128k, -af, aresample=async=1, -c:v, libx264, -preset, veryfast, -profile:v, main, -level, 3.1, -pix_fmt, yuv420p, -r, 30, -crf, 25, -g, 60, -tune, zerolatency, -f, mp4, /tmp/recordings/smqehokzamlnhkkg/1212121212_2022-03-03-11-29-34.mp4])
2022-03-03 11:29:39.145 INFO: [90] [session_id=smqehokzamlnhkkg] FfmpegCapturer.onFfmpegStateMachineStateChange#130: Ffmpeg capturer transitioning from state Starting up to Running
2022-03-03 11:29:39.148 INFO: [90] [session_id=smqehokzamlnhkkg] StatefulJibriService.onServiceStateChange#39: File recording service transitioning from state Starting up to Running
2022-03-03 11:29:39.149 INFO: [90] XmppApi$createServiceStatusHandler$1.invoke#260: Current service started up successfully, sending on iq <iq xmlns='jabber:client' to='jibribrewery@internal.auth.test.heyjoe.io/focus' id='3VFRP-52' type='set'><jibri xmlns='http://jitsi.org/protocol/jibri' status='on'/></iq>

Specs of the machine running jibri? Is that the only thing running there?

Yes. it’s the only thing running.

the machine is aws m5zn.large
m5zn.large 2 cpu Ram 8 GiB net speed Up to 25 Gbps

2CPU is way too low to run Jibri. 2vCPU is even worse. And if you’re running Jibri with its default resolution, guaranteed, this server will crash.