dify
dify copied to clipboard
enhancement:support Qdrant gRPC mode
Description
According my test,gRPC mode seems take lower latency than REST mode.
| 次数 | search (HTTP)latency(s) | search (gRPC)latency(s) | scroll(HTTP) latency(s) | scroll (gRPC)latency(s) | client(HTTP)初始化 | client(gRPC)初始化 |
|---|---|---|---|---|---|---|
| 1 | 0.0489 | 0.0157 | 0.0132 | 0.0129 | 0.0043 | 0.0029 |
| 2 | 0.0490 | 0.0166 | 0.0129 | 0.0105 | 0.0037 | 0.0043 |
| 3 | 0.0453 | 0.0128 | 0.0172 | 0.0089 | 0.0028 | 0.0029 |
| 4 | 0.0569 | 0.0092 | 0.0164 | 0.0099 | 0.0040 | 0.0023 |
| 5 | 0.0494 | 0.0134 | 0.0136 | 0.0085 | 0.0032 | 0.0017 |
| avg | 0.0491 | 0.0135 | 0.0148 | 0.0107 | 0.0036 | 0.0028 |
User guide
docker deployment
- We can enable gRPC mode by setting these environment variables in api and worker container in docker-compose.yaml:
QDRANT_GRPC_ENABLED: 'true'
QDRANT_GRPC_PORT: xxxx
- Add port mapping to port 6334 of the qdrant container as below:
qdrant:
image: langgenius/qdrant:v1.7.3
restart: always
volumes:
- ./volumes/qdrant:/qdrant/storage
environment:
QDRANT_API_KEY: 'difyai123456'
# uncomment to expose qdrant port to host
ports:
- "6333:6333"
- "xxxx:6334"
- You can replace
xxxxto your port
source deployment(api)
- Add 2 lines to api/.env as below:
QDRANT_GRPC_ENABLED=true
QDRANT_GRPC_PORT=xxxx
- You can replace
xxxxto your port
Fixes # (issue)
Type of Change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update, included: Dify Document
- [x] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
- [ ] Dependency upgrade
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
- [ ] TODO
Suggested Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings
- [ ] I ran
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods - [ ]
optionalI have made corresponding changes to the documentation - [ ]
optionalI have added tests that prove my fix is effective or that my feature works - [ ]
optionalNew and existing unit tests pass locally with my changes