SanicLLMPiAB: Sanic Web Framework on Raspberry Pi for Localized LLMs for Apache Benchmark Analysis
摘要
Deploying large language models (LLMs) on resource-constrained edge devices remains a significant systems challenge due to limited CPU capacity, restricted memory, absence of hardware accelerators, and the need for low-latency, privacy-preserving operation without cloud connectivity. Existing approaches primarily emphasize model compression, energy profiling, or hybrid cloud–edge architectures, but lack systematic evaluation of end-to-end LLM behavior when exposed as concurrent, web-accessible services on single-device edge platforms. In particular, the interaction between quantized LLM inference, asynchronous web serving, and request-level concurrency remains poorly understood. This paper presents SanicLLMPiAB, a fully localized and internet-independent framework for evaluating quantized LLM inference on a Raspberry Pi 4B using an asynchronous Sanic web server, the Ollama local LLM runtime, and Apache Bench–driven stress testing. Unlike prior model-centric studies, the proposed framework enables fine-grained, per-request observability by capturing token-level execution metrics, end-to-end latency, CPU utilization, memory stability, and accuracy under controlled concurrency. All inference is executed locally, ensuring data privacy and eliminating network variability. Experimental evaluation of four quantized LLMs (Qwen 0.5B, TinyLLaMA, TinyDolphin, and StableLM2) demonstrates that Qwen 0.5B achieves the best balance of scalability and robustness, sustaining stable throughput (11–12 tokens/s), sub-second end-to-end latency at higher concurrency, and 100% response accuracy. In contrast, larger models exhibit severe latency inflation, instability, and execution failures under moderate load. Statistical analyses (ANOVA, MANOVA, CCA, and hierarchical clustering) confirm concurrency as the dominant factor shaping edge inference behavior. These results establish SanicLLMPiAB as a practical, reproducible foundation for secure and scalable LLM deployment on edge devices. The code is hosted on https://github.com/ParthaPRay/Sanic-Ollama-RaspberryPi-API.