PuppyIP Resource Center
Cloud Operations 10 min read Published 2026-11-17

Run native sd2api beside Sub2API on Ubuntu: isolate users, ports, and data

sd2api and an existing Sub2API service should use separate users, directories, ports, and data boundaries. An open browser or VNC page does not prove the API, database, or real account workflow passed.

sd2api Sub2API Ubuntu systemd SQLite PostgreSQL

Service eligibility and regional restrictions

PuppyIP serves only compliant overseas businesses and their authorized personnel. Proxy services are not available in mainland China. The service may only be used for lawful business activities outside mainland China. Use of this service within mainland China is prohibited.

Hosting a proxy IP or server overseas does not change these restrictions. The service must not be provided to end users in mainland China through relaying, forwarding, sharing or resale. Before use, read the Terms of Service.

Key Takeaways

  • Keep Sub2API PostgreSQL/Redis separate from sd2api’s venv and SQLite file.
  • Separate directories and virtual environments do not isolate ports, process permissions, or resources automatically.
  • CPUQuota=75% is about 0.75 logical CPU; 700M/900M are capacity-assessment examples only.
  • Check the browser, API, WebSocket/RFB, database, and account workflow separately.

Define the runtime boundary of both services

This guide covers adding sd2api to Ubuntu beside an existing native Sub2API service. The existing service uses PostgreSQL and Redis; the selected public sd2api release uses its own Python environment and SQLite. Check both versions, then allocate a separate user, systemd unit, directory, and listener for the new service.

sd2api and Sub2API are different projects. Similar names do not make their installation instructions, databases, or configuration interchangeable. Preserve the existing PostgreSQL/Redis services and application data, add only the new service’s dependencies, and recheck each project’s public documentation when upgrading.

Inspect the existing unit and plan a separate port

Before creating a unit, read the existing service state, working directory, startup arguments, and EnvironmentFile location. Inspect this output locally because it may reveal internal paths or secret references. Check current listeners, then choose a nonconflicting port for the new service. Distinguish the browser entry point, app API, database, and VNC/RFB service.

Create a separate system user and service data directory for sd2api, limiting it to its own code, virtual environment, and SQLite file. A Python virtual environment isolates package versions, not process permissions, CPU, memory, network, or database contents. Separate directories do not guarantee port or data isolation.

Inspect existing Sub2API unit metadata

shell
SERVICE_UNIT=REPLACE_WITH_EXISTING_SERVICE_UNIT.service
sudo systemctl show "$SERVICE_UNIT" --property=LoadState,ActiveState,SubState,WorkingDirectory,ExecStart,EnvironmentFiles --no-pager
Reads unit metadata only. Output may expose local paths or arguments; do not share raw output.

Inspect listening-port snapshot

shell
ss -ltn
Read-only listener snapshot. A currently unused port is not reserved; confirm the new service port and bind address.

Keep the venv and SQLite file inside the new service boundary

Create the Python venv in a directory owned by the new service user, then install dependencies using the public instructions for the pinned sd2api version. Do not mix dependencies into system Python or place the SQLite file in Sub2API’s PostgreSQL/Redis data directory. Protect the SQLite file with explicit permissions and a separate backup, using only the database mode supported by that release.

If that release does not support SQLite or needs concurrent writers, stop and provision a separate database officially supported by the project. Do not casually point the new app at the existing production database. A separate SQLite file does not replace backups, migrations, or file-access controls.

Create a venv in a service-owned directory

shell
python3 -m venv REPLACE_WITH_SERVICE_OWNED_DIRECTORY/venv
Run in a separate directory writable by the new service user; this does not install app dependencies. Do not reuse Sub2API or another service’s virtual environment.

Measure resources before adding systemd limits

Measure CPU, memory, disk, and restart behavior while both services run before adding a separate systemd drop-in. CPUQuota=75% caps CPU time at about 75% of one logical CPU. MemoryHigh=700M is a reclaim and throttling threshold; MemoryMax=900M is a hard limit that can trigger an OOM kill within the unit if memory cannot be contained. These are hypothetical examples, not measured host capacity or universal settings.

A memory cap can trigger reclaim, restarts, or task failures, while a CPU cap can reduce throughput. Check available memory and workload peaks, preserve the prior unit configuration, and change one service in a maintenance window with rollback ready. Do not apply the same values to multiple services or infer capacity from a short idle period.

Illustrative systemd drop-in resource limits

ini
[Service]
CPUQuota=75%
MemoryHigh=700M
MemoryMax=900M
Illustrative only, not proof of host capacity: CPUQuota=75% is about 0.75 of one logical CPU; assess 700M/900M against available memory, peak load, and systemd behavior. Apply in a maintenance window with rollback ready.

Verify the browser, API, database, and VNC separately

Check both systemd units, listeners, and database connections first, then inspect the sd2api browser page, read-only API, SQLite file permissions, and application logs. A healthy Sub2API page or API does not prove that sd2api initialized. A static page returning HTTP 200 does not prove that the backend selected the right database.

With noVNC, the browser page, WebSocket, RFB handshake, and displayed desktop are separate checks. Use the application’s documented secure entry and synthetic or authorized test accounts to verify each stage. An open page does not establish a successful account login, advertising task, or downstream workflow.

Roll back only the new service and its route

If the new service is unhealthy, stop or restore only sd2api’s own unit, data directory, and newly added ingress route. Do not delete Sub2API’s database, Redis, other application files, shared proxy configuration, or management path. For an unknown failure, inspect redacted errors and unit state instead of rerunning an installer, clearing a database, or creating accounts to guess.

Record baselines and versions for both services, including unit, database, API, and browser/VNC checks. One passing check cannot replace full acceptance. Raw environment files, identity credentials, and private host details do not belong in articles or support screenshots.

Sources

Frequently Asked Questions

Does a virtual environment isolate CPU, ports, and databases?

No. A venv mainly isolates Python packages. Configure service users, working directories, listeners, database files, and systemd resource controls separately.

Are the sample CPUQuota and memory values right for my server?

Do not assume so. 75% is about 0.75 of one logical CPU; 700M/900M are capacity-assessment examples. Measure memory and workload, then plan a maintenance window and rollback.

Does an HTTP 200 page prove VNC or account access?

No. The browser page, API, WebSocket/RFB, authentication, and real business workflow are separate acceptance checks.