Benchmarking Local LLM Deployment Performance and SQL Generation in Production-Oriented Scenarios
As large language models move into enterprise workflows, local and private-cloud deployments have become a common way to protect data security and ensure business continuity. But once detached from massive cloud compute clusters, LLMs face real challenges: inference performance on limited hardware, and actual capability on complex vertical tasks such as structured data querying. This article analyzes hands-on benchmark data from local deployments of mainstream LLMs, focusing on two dimensions—"inference performance" and "SQL generation"—and shares practical optimization takeaways.
With large language models increasingly integrated into enterprise applications, local or private-cloud deployment has become an important option for safeguarding data security and business continuity. However, once separated from the massive compute clusters of the cloud, LLMs face real challenges in inference performance on limited local hardware—and in their true capability on complex vertical tasks such as structured data querying. Based on recent hands-on benchmarking of mainstream LLMs running locally, this article provides a deep dive into two core dimensions—inference performance and SQL generation—and shares related optimization practices.
1. Local Inference Performance: Benchmarks and Bottlenecks
In local deployment scenarios, inference performance directly determines response latency and throughput for downstream services. Our benchmarks focused on three key metrics: prefill speed, decode speed, and time-to-first-token (TTFT).
1.1 Throughput and Decode Speed
In single-concurrency scenarios, prefill peak throughput reached about 757 tok/s (at a 4K context), holding steady at 629-758 tok/s across the 2K-32K range, with no obvious degradation as context length grew. During decoding, single-concurrency speed remained stable at 23.8-28.7 tok/s. This baseline shows the model handles long single inputs with solid foundational capability.
1.2 Performance Degradation Under Concurrency
Real-world workloads, however, typically involve concurrent requests. Our tests showed that prefill throughput degrades sharply as concurrency rises: a 30-45% drop at 2 concurrent requests, about 50% at 4, and up to 63% at 6 (at 2K context length, throughput fell from 688 tok/s to 228 tok/s).
Decoding also suffers under concurrency. 8-18 tok/s is the typical range, but with long prompts (16K/32K) combined with 4-6 concurrent requests, speed drops into the 8-11 tok/s trough. This indicates fierce contention for GPU memory bandwidth and compute resources in high-concurrency, long-context scenarios.
1.3 Latency Bottlenecks and Parameter Tuning
TTFT grows roughly linearly with input length. At 32K context, single-concurrency TTFT was 51.5 seconds, ballooning to 186.4 seconds at 6 concurrent requests. Deeper analysis showed queuing was the primary culprit: the inference engine (e.g., a typical vLLM setup) defaults to max-num-seqs=2, so when concurrent requests exceed that threshold, new requests queue up, long prefill tasks block each other, throughput gets shared, and latency climbs sharply.
Optimization direction: Raising max-num-seqs and max-num-batched-tokens can effectively improve throughput under high concurrency—but memory usage must be weighed carefully. Our measurements showed GPU memory utilization already at 0.91, with KV Cache close to full. Blindly increasing the number of concurrent sequences risks OOM (Out of Memory). Developers should combine actual GPU memory capacity with load testing to find the right balance, or consider elastic compute instances or container platforms—such as those offered by Baidu AI Cloud—to dynamically scale GPU resources during traffic peaks and relieve queuing pressure.
2. Analyzing LLM Structured Query (SQL) Generation
One of the core use cases for LLMs in data analytics is converting natural language to SQL (NL2SQL). To evaluate this, we built a test set of 25 questions across difficulty levels and ran them through an automated tool-calling loop.
2.1 Automated Execution and Baseline Capability
The test pipeline used a standard tool-calling pattern: the model generates SQL → a local execution engine runs it → results are verified → success or failure is judged. Across the 25 questions, the model performed strongly on easy cases, autonomously completing the full tool-calling loop and correctly handling complex multi-table JOINs and window functions (such as LAG, ROW_NUMBER, and cumulative share calculations). Overall logical construction ability was solid.
2.2 Precision and Format Control: The Main Failure Points
Despite good reasoning, the overall pass rate was only 36.0% (9/25) under strict evaluation criteria—which required exact matching of row counts, column counts, column names, and first-row string values. The biggest failure point was format precision control. The model frequently omitted the explicitly required ROUND(..., 2) function, leading to 15 out of 20 questions being “logically correct, one decimal place short.”
Some harder questions showed structural failures as well. For example, in a multi-table join combined with a discount CTE, the final returned column names failed to align with the expected output. When computing quarter-over-quarter (QoQ) growth with window functions, the model returned 0 rows with mismatched column names. On channel-attribution logic, the model occasionally miscalculated the intended channel share.
2.3 Token Consumption and Iteration Cost
During tool calling, easy questions averaged only 2 steps (about 2.4k tokens consumed), while hard questions averaged 6.1 steps. Some extremely complex problems required 14-17 iterations and consumed over 55k tokens. Multi-round self-correction demonstrates the model’s reasoning depth, but it also brings substantial compute overhead and accumulating latency.
3. Optimization Practices and Recommendations
Given the performance and capability findings above, enterprises deploying LLMs can optimize along the following dimensions:
3.1 Strengthening Prompt Engineering
For format-sensitive tasks like SQL generation, constraints must be reinforced in the system prompt. For example: explicitly require that “ROUND and the specified decimal places must be used exactly as stated in the question” and that “returned column names must exactly match the aliases given in the question.” For complex scenarios such as window functions, embed few-shot example SQL in the prompt to guide the model toward correct structured syntax and reduce wasted iterations.
3.2 Tuning Inference Engines and Resource Scheduling
When deploying locally or in the cloud, inference engine parameter configuration is critical. Adjust max-num-seqs dynamically based on your traffic profile (e.g., proportion of long inputs, concurrency peaks). When GPU memory is tight, explore techniques like PagedAttention to further improve KV Cache efficiency. At the architecture level, combine logging and monitoring/alerting systems—such as those available from Baidu AI Cloud—to track memory utilization and request queue depth in real time, enabling early warning and elastic scaling.
3.3 Matching Evaluation Criteria to Real Business Scenarios
During testing, we recommend a dual-track evaluation approach: keep strict standards to expose model weaknesses, while also allowing relaxed precision tolerance (e.g., an error margin of 1e-6) to assess real-world “usability.” Our tests showed that relaxing the precision constraint raised the pass rate to 88%. The takeaway: in practice, you can handle output formatting logic at the application layer, letting the LLM focus on complex business reasoning rather than struggling over string formats.
Overall, LLMs in local deployments and vertical scenarios show strong logical reasoning potential, but also expose concurrency bottlenecks and weak fine-grained control. Through careful inference parameter tuning, business-aligned prompt engineering, and solid cloud-native infrastructure, developers can maximize the value of LLMs and achieve efficient, stable production deployments.
