GPU time-slicing quietly breaks your store’s AI features

The chat widget on the store answers in about a second most of the time, then occasionally hangs for several seconds while your uptime monitor stays green. That pattern is what GPU time-slicing does to the fast feature that shares a card with a heavy one. It’s nearly invisible if you watch averages.

Anubhab Banerjee measured this properly in a post on Towards Data Science, running two agent workloads in separate Kubernetes pods on a single GTX 1080. The numbers are worth understanding before you put several AI features on one box. The short version: sharing was nearly free on the median and expensive on the tail.

What GPU time-slicing costs

The NVIDIA Kubernetes device plugin can advertise one physical GPU as several. You apply a ConfigMap that sets replicas: 4, the node reports four allocatable nvidia.com/gpu slots, and four pods can each request a whole GPU and all get scheduled. NVIDIA’s time-slicing docs say it plainly: this buys no memory or compute isolation, just the GPU context-switching between containers.

Banerjee’s run paired a small, latency-sensitive FFT worker with a heavy matmul worker. The small one’s p50 barely moved, 3.598 ms solo versus 3.593 ms shared, so the median said nothing happened. Its p99 went from 3.679 ms to 6.101 ms, about 1.66x, and its jitter, p99 over p50, went from 1.02 to 1.70. Throughput fell 7.3% for the small worker and 1.4% for the heavy one, and every pod reported Running throughout. He cross-checked with DCGM hardware counters, so the numbers aren’t a stopwatch artifact. The profiler behind the run is on GitHub.

The asymmetry matters. Time-slicing hands out turns and does nothing for deadlines, so the workload that lives by its deadline pays for every context switch while the heavy one mostly shrugs. In a store’s AI stack, the small twitchy workloads are the router, review triage, and the tool-caller. The heavy steady work is the embeddings rebuild or an image description batch. Share one card and the fast feature is the one that stalls.

How to check for it in a WooCommerce setup

Most stores aren’t on Kubernetes, but the same shape shows up with Ollama or vLLM on one box serving chat completions, an embeddings job, and a recommendation feature. Four steps:

  • Name your AI workloads and mark which ones have a deadline. A chat reply has one. A nightly embeddings rebuild doesn’t.
  • Move the deadline-free work off peak hours. In WordPress terms, queue it in Action Scheduler for 3 a.m. instead of firing it while customers are chatting.
  • Log per-request latency from PHP and read percentiles, not the mean.
  • Compare solo against shared. Fire the same request with the batch job off, then again while it runs. If the p99 only blows up when the batch is running, you have contention, and swapping models won’t fix it.

For the logging part, a wrapper like this is enough to get started:

<?php
function bbioon_timed_llm_call( string $prompt ): string {
    $start = microtime( true );
    $reply = bbioon_call_llm( $prompt ); // your existing call to Ollama or vLLM
    $ms    = ( microtime( true ) - $start ) * 1000;

    error_log( sprintf( 'LLM_LATENCY,%.1f', $ms ) );
    return $reply;
}

A note on the measurement itself: Banerjee timed with CUDA events and a synchronize, because host-side timing can mislead in the other direction. It reports how long Python took to ask rather than how long the GPU worked. From PHP you get wall clock, which includes queue wait. For the store-facing question that’s the right number anyway, since the customer also waits in wall clock. Collect a few hundred lines, sort them, and read the 95th and 99th values. A healthy average next to a wrecked tail means the feature is broken while the dashboard says otherwise.

If you’re weighing a local inference box against a hosted API for store features, or you already run local models and see flaky response times, that’s the kind of work I take on: wire the latency logging, run the solo-versus-shared comparison, and say which way the numbers point.

When this isn’t your problem

If you run one model and serve one request at a time, contention isn’t your bottleneck. The stalls are more likely model size, a long context, or a PHP timeout, so look there before blaming the GPU.

If your AI traffic is a few hundred calls a day, a hosted API is usually cheaper too, because the provider absorbs the sharing problem and you skip a box that idles most of the time. Whether that trade is right depends on where the store’s data is allowed to go.

I can’t tell you whether Ollama’s internal scheduling behaves like the CUDA time slices in the source. I haven’t measured that, and the source’s numbers are Kubernetes-specific. The direction holds for any shared GPU with no isolation: the latency-sensitive workload degrades first and the medians hide it. So run one week of p99 logging on the feature you already have before buying hardware.

author avatar
Ahmad Wael
I'm a WordPress and WooCommerce developer with 15+ years of experience building custom e-commerce solutions and plugins. I specialize in PHP development, following WordPress coding standards to deliver clean, maintainable code. Currently, I'm exploring AI and e-commerce by building multi-agent systems and SaaS products that integrate technologies like Google Gemini API with WordPress platforms, approaching every project with a commitment to performance, security, and exceptional user experience.

Leave a Comment