This project demonstrates how to set up and use SQL Server with vector embeddings, including:
- Restoring the StackOverflow sample database
- Generating and storing text embeddings using external models (Ollama)
- Load balancing and performance testing with Nginx
- Docker & Docker Compose
- Ollama
-
Clone the repository
git clone https://github.com/your/repo.git cd ollama-lb-sql -
Restore the StackOverflow Database
The
restore_stackoverflow.sqlscript attaches the database files.
Make sure the MDF/NDF/LDF files are present in/var/opt/mssql/data/inside the SQL Server container.CREATE DATABASE StackOverflow_Embeddings_Small ON (FILENAME = N'/var/opt/mssql/data/StackOverflow2013_1.mdf'), (FILENAME = N'/var/opt/mssql/data/StackOverflow2013_2.ndf'), (FILENAME = N'/var/opt/mssql/data/StackOverflow2013_3.ndf'), (FILENAME = N'/var/opt/mssql/data/StackOverflow2013_4.ndf') LOG ON (FILENAME = N'/var/opt/mssql/data/StackOverflow2013_log.ldf') FOR ATTACH ;
-
Start the Services
docker compose up -d
This will start:
- SQL Server
- Nginx load balancer
- Certificate generator
-
Configure Nginx for Connection Pooling
The
nginx.confis set up for high concurrency and connection pooling.Key settings:
keepalive 256;in theupstreamblockproxy_set_header Connection "";in eachlocationblock
-
Generate Embeddings
Use the provided T-SQL scripts (see
vector-demos.sql) to generate and store embeddings via the external model endpoints. -
Load Testing
Use
test.ps1to simulate concurrent API calls and measure performance.pwsh ./test.ps1
Adjust
$totalWorkand$threadsin the script as needed.