Quickly deploy an inference service based on the DeepSeek model

更新时间:
复制 MD 格式

OSS Connector for AI/ML lets you load large inference models directly from OSS at full network bandwidth. This tutorial deploys a 664 GB DeepSeek-R2 model on a single node using llama.cpp, then shows how to scale that deployment to a multi-node cluster using a peer-to-peer (P2P) distribution system.

Choose a hardware configuration

This tutorial uses ecs.g8i.48xlarge: 192-core CPU, 1 TiB of memory, and a 100 Gbit/s base network bandwidth.

How OSS Connector for AI/ML works

OSS Connector for AI/ML intercepts file I/O calls at the OS level using LD_PRELOAD, redirecting reads to OSS without requiring changes to your inference framework.

Key capabilities:

  • Out-of-the-box integration: Works with mainstream frameworks without code modification.

  • 100 GB models in seconds: User-mode I/O delivers performance several times higher than Filesystem in Userspace (FUSE)-based tools.

  • 100% bandwidth utilization: A self-developed high-concurrency network module fully saturates OSS throughput.

  • Smart prefetch cache: Preloads hot data into memory to reduce inference latency.

Why use OSS for model loading

AdvantageDetails
High throughput and concurrencyDistributed architecture supports parallel reads across multiple data clusters. Stateless access endpoints scale horizontally to fully utilize available network bandwidth.
Low-cost tiered storageObject versioning tracks model iterations automatically. Lifecycle policies automate storage class transitions to reduce long-term retention costs.
High reliability99.9999999999% (12 nines) data durability and 99.995% availability keep inference services running without storage-related interruptions.
Efficient distributionNatively suited for distributed access across inference nodes. Fine-grained authorization policies enable secure model sharing across teams.

Prerequisites

Before you begin, make sure you have:

  • An ECS instance of type ecs.g8i.48xlarge

  • An OSS bucket in the same region as your ECS instance, with oss:ListObjects permission on the target directory

  • The Q8-quantized GGUF version of DeepSeek-R2 (664 GB) uploaded to the bucket via the internal endpoint using ossutil (upload reference)

Deploy the inference service on a single node

Step 1: Set up the network environment

  1. Create an ECS instance on the Elastic Compute Service (ECS) instances page, using the ecs.g8i.48xlarge instance type.

    screenshot_2025-08-07_15-09-05

  2. Create an Elastic Network Interface (ENI) on the ENIs page. The ENI must be in the same virtual private cloud (VPC) as the ECS instance. Aggregating bandwidth from multiple ENIs lets you exceed the single-ENI bandwidth cap when accessing OSS within the VPC.

  3. Attach the ENI to the ECS instance.

  4. Note the IP addresses of the attached ENIs — you will need them when configuring OSS Connector.

    image \(2\)

Step 2: Install the inference framework

This tutorial uses llama.cpp, which supports efficient loading and inference of GGUF-format models.

To build from source:

git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
mkdir build
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

Step 3: Install OSS Connector

  1. Download and install the package.

       wget https://gosspublic.alicdn.com/oss-connector/oss-connector-lib-1.1.0rc7.x86_64.rpm
       yum install -y oss-connector-lib-1.1.0rc7.x86_64.rpm
  2. Edit the configuration file at /etc/oss-connector/config.json.

       {
           "logLevel": 1,
           "logPath": "/var/log/oss-connector/connector.log",
           "auditPath": "/var/log/oss-connector/audit.log",
           "expireTimeSec": 120,
           "prefetch": {
               "vcpus": 32,
               "workers": 32
           }
       }

Step 4: Configure OSS Connector

Set the following environment variables so OSS Connector can authenticate and locate the model:

export OSS_ACCESS_KEY_ID=<your-access-key-id>
export OSS_ACCESS_KEY_SECRET=<your-access-key-secret>
export OSS_REGION=cn-beijing
export OSS_ENDPOINT=oss-cn-beijing-internal.aliyuncs.com
export OSS_PATH=oss://<BUCKET-NAME>/deepseek/DeepSeek-R2-Q8_0/
export MODEL_DIR=/tmp/model/DeepSeek-R2-Q8_0/
export HTTP_SOURCE_IP=172.xx.x.xxx,172.xx.x.xxx
VariableDescription
OSS_ACCESS_KEY_IDAccessKey ID of an Alibaba Cloud account or Resource Access Management (RAM) user. When using a temporary Security Token Service (STS) credential, set this to the credential's AccessKey ID. If the bucket supports anonymous access, leave this blank.
OSS_ACCESS_KEY_SECRETAccessKey secret corresponding to OSS_ACCESS_KEY_ID.
OSS_SESSION_TOKENTemporary access token when using STS credentials. Leave blank when using an AccessKey pair directly.
OSS_ENDPOINTOSS service endpoint, for example http://oss-cn-beijing-internal.aliyuncs.com. Defaults to HTTPS if no protocol is specified. Use HTTP on internal networks for better performance.
OSS_REGIONOSS region ID, for example cn-beijing. If not set, authentication may fail.
OSS_PATHOSS path to the model directory in oss://bucketname/path/ format, for example oss://examplebucket/deepseek/DeepSeek-R2-Q8_0/.
MODEL_DIRLocal path where the connector maps model files, for example /tmp/model/DeepSeek-R2-Q8_0/.
HTTP_SOURCE_IPComma-separated IP addresses of the ENIs for the connector to use (for example 172.16.6.121,172.16.6.122). Linux automatically selects the corresponding network interfaces and routes traffic based on these IPs. For fine-grained traffic splitting by source IP or destination address, configure policy-based routing with ip rule and custom route tables.

Step 5: Start the inference service

LD_PRELOAD=/usr/local/lib/libossc_preload.so ENABLE_CONNECTOR=1 llama-server \
  -m /tmp/model/DeepSeek-R2-Q8_0/DeepSeek-R2.Q8_0-00001-of-00015.gguf \
  -t 48 -c 1024 --host 0.0.0.0 --port 9090 --numa isolate

LD_PRELOAD loads the OSS Connector library before the process starts, intercepting I/O calls transparently.

Step 6: Verify performance

After the service starts, internal network bandwidth on the ECS instance saturates within about one minute:

image

Both ENIs run at capacity, with combined bandwidth held continuously at 100 Gbit/s:

image \(1\)

The following table compares end-to-end startup time across loading tools. Startup time is measured from process launch to when llama.cpp logs that the model is ready.

Loading toolEnd-to-end startup timeOSS single-account bandwidth limitActual bandwidth usedTotal data read from OSS
OSS Connector for AI/ML81s100 Gbit/s100 Gbit/s664 GB
ossfs 2.0257s100 Gbit/s20 Gbit/s666 GB
ossfs 1.01020s100 Gbit/s6.4 Gbit/s782 GB

Scale to large inference clusters with P2P distribution

Overview

When hundreds of inference nodes start simultaneously and all pull the same model from OSS, concurrent back-to-origin traffic can exceed single-account bandwidth limits and slow startup across the cluster.

OSS Connector for AI/ML can work with a peer-to-peer (P2P) distribution system designed for this scenario. Nodes share model data with each other, reducing the load on OSS while preserving the connector's low-latency, high-throughput initial data access. The system supports on-demand distribution and can perform random and streaming reads of large files.

Key properties:

  • Peak traffic reduction: Node-to-node sharing cuts direct OSS requests during concurrent startup, reducing instantaneous pressure on the central data source.

  • Sustained performance: Raw data is still pulled from OSS via the connector, preserving low latency and high throughput for initial access.

  • Horizontal scaling: Supports clusters of hundreds of nodes with startup times close to single-node performance.

  • Reduced back-to-origin traffic: Local caching and P2P sharing minimize repeated data pulls from OSS, improving overall resource utilization.

Test environment

ParameterValue
ModelDeepSeek-R2, Q8-quantized GGUF format, 664 GB
Cluster50 ecs.g8i.48xlarge instances managed by Container Service for Kubernetes (ACK)
Frameworkllama.cpp running as the main process in each container
MeasurementStartup time per node from process launch to the llama.cpp model-ready log entry

Test results

Average end-to-end startup timeOSS single-account bandwidth limitTotal data read from OSS
127s100 Gbit/s1,262 GB

Key findings

The average startup time across 50 nodes was approximately 1.5x that of a single node (127s vs. 81s). Total back-to-origin data volume was about 1,262 GB — roughly twice the 664 GB model size — because each unique data block was fetched from OSS once and then distributed via P2P to the remaining nodes.

Even in this high-concurrency environment, startup times remained stable and did not increase proportionally with the number of nodes, demonstrating effective horizontal scaling.

Related resources