
What it is
JobWhisper's interview copilot listens to a live interview and shows the candidate an answer while the interviewer is still talking. I led the frontend, and I worked on this live path in both the app and the server.
The problem
On a good connection the question shows up as text about half a second after the interviewer stops talking. That is the baseline for a good connection.
Customers on weak connections told us the answers came very late, or never came at all. An answer that shows up after the conversation has moved on is no use to anybody.
We had no number for a weak connection. We only had complaints.
First, make it fail on my desk
Before changing anything, I built a small test rig to reproduce the problem. It plays two spoken questions with noisy silence between them, the way a real interview sounds, and sends them through a throttle that caps the upload speed.
The first run was worse than the complaints. At 300 kbps the second question took about 20 seconds to arrive. At 150 kbps it never arrived. I stopped waiting after 35 seconds.
The hard part
Three problems combined to make slow connections fail, and each made the next worse.
- We were sending everything. The app sent raw audio, about 520 kbps for each audio source, with the silence included. A call is mostly the other person talking, or nobody talking, and we were uploading all of it.
- Nothing slowed the sender down. When the line was full the audio just queued up. Every question waited behind the backlog from the one before it. That is why the second question was so much worse than the first.
- The server gave up on slow clients. A client buried in its own backlog could not answer the server's "are you there" check in time. So the server decided the client was gone, hung up, and threw the question away.
Fixing the audio upload alone would still have left the server dropping slow clients.
Decisions and tradeoffs
Stop sending silence
I added a gate on the audio. It opens when the sound gets louder than a low threshold, and it closes after the speech stops. It has to keep the start of each word and stay open long enough to close each turn.
The first syllable. If the gate opens only when it hears speech, the start of the word is already gone. So the gate always keeps the last 300 ms in hand and sends that first.
The end of the turn. I first set the tail to 2 seconds. That was wrong. The speech-to-text side decides a person has finished by hearing silence, and that silence window can be set as high as 3 seconds. If my tail is shorter than the window, the turn never closes and no answer comes until somebody speaks again. So I set it to 3.5 seconds, which covers every allowed setting.
What it cost Pauses shorter than 3.5 seconds are sent in full. We still skip the long silences, which is most of a call. In the test, 141 of 316 audio frames were sent, 55% less.
I also set the open threshold low on purpose, below every speech detector further down the line. If I am wrong about that, the gate stays open in a noisy room. We save no data, but we lose no words. I chose the failure that wastes data over the one that cuts speech.
Keep the line warm
With the gate closed we send nothing, and I did not know if the speech-to-text provider would drop a connection that goes quiet. So I tested it. With zero bytes for about 16 seconds, it dropped and reconnected. With one quiet frame every 5 seconds, it held for 90 seconds of silence with no problem. The keepalive stayed.
Compress the socket
I turned on compression for the live connection. It was a measured win on the wire.
What it cost CPU and memory on the server for every open call. I wrote that down for DevOps to watch after release.
Drop the drafts, never the state
When the client's download side backs up, the server now drops the messages that replace each other: the half-finished transcript, and the answer as it streams in. The next one replaces the last one anyway, so nothing is lost.
It never drops heartbeats or state changes. The code review caught that I had made retractions droppable too, which would have left a wrong answer on screen. I fixed it and added a test that fails without the fix.
The review also found that the operating system's own buffers hide most backlogs from the server, so this dropping rarely triggers. I kept it, because it only ever drops a message the next one replaces.
Slow is not dead
On the server, any message from the client now counts as proof it is alive, not only the reply to a ping. On the client, a connection that is still draining its queue counts as alive. I also fixed an off-by-one that had been flagging every connection as weak.
What it cost A link that is really dead is now noticed in about 9 seconds, up from about 6. I accepted that, because a switch from wifi to mobile data is still caught in about 2.5 seconds by the network-change signal.
Screenshots: lower the quality, never the size
The coding copilot reads the candidate's screen. On a weak link it now sends a lighter image, but at full size. The AI reads code from that image, so I kept the full size and let only the quality drop.
What I chose not to build
A limit that throws away audio older than a few seconds. It is the obvious fix, and I left it out. It could drop the bit of silence that closes a turn, and then there is no answer at all. The gate already drains the backlog during the pauses.
Result
The second question at 300 kbps went from about 20 seconds to under 2.
At 150 kbps it went from never arriving to 5.2 seconds. These are the times for the question to arrive as text, measured on the throttled test rig.
The "before" numbers are kinder than what customers saw, because I measured the old app against the fixed server. Against the old server, the second question was dropped even at 300 kbps.
What was still wrong
At 150 kbps the first question still took 8 seconds. The lag that was left was the speech itself. Raw audio is too heavy for that line even when it is compressed, and no gate fixes that.
That became the next project: a lighter audio format that sends about 16 times less data on that link.
What I took from it
Without the throttle I would have guessed "compress it", seen a small win and stopped. The server would still be hanging up on every slow client.