用 docker-compose 构建了一个服务,mongodb 里面载入了几百万数据,数据查询慢的无法忍受, 但是实体机上几乎是瞬间完成, docker 就非常非常慢, 我的 docker 版本是:17.03.1-ce,
mongodb_1 | 2017-06-14T08:33:53.167+0000 I QUERY [conn84] query Info.info_b query: { geoname_id: 7533614 } planSummary: COLLSCAN cursorid:10038145745 ntoreturn:0 ntoskip:0 keysExamined:0 docsExamined:1818459 keyUpdates:0 writeConflicts:0 numYields:14206 nreturned:101 reslen:5141 locks:{ Global: { acquireCount: { r: 28414 } }, Database: { acquireCount: { r: 14207 } }, Collection: { acquireCount: { r: 14207 } } } 613ms
mongodb_1 | 2017-06-14T08:33:53.559+0000 I QUERY [conn84] getmore Info.info_b query: { geoname_id: 7533614 } cursorid:10038145745 ntoreturn:0 cursorExhausted:1 keyUpdates:0 writeConflicts:0 numYields:8854 nreturned:219 reslen:11230 locks:{ Global: { acquireCount: { r: 17710 } }, Database: { acquireCount: { r: 8855 } }, Collection: { acquireCount: { r: 8855 } } } 389ms
mongodb_1 | 2017-06-14T08:33:53.569+0000 I NETWORK [conn84] end connection 172.18.0.4:60124 (0 connections now open)
mongodb_1 | 2017-06-14T08:33:53.570+0000 I NETWORK [initandlisten] connection accepted from 172.18.0.4:60128 #85 (1 connection now open)
mongodb_1 | 2017-06-14T08:33:54.555+0000 I QUERY [conn85] query Info.info_b query: { geoname_id: 8223931 } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 keysExamined:0 docsExamined:2951856 cursorExhausted:1 keyUpdates:0 writeConflicts:0 numYields:23061 nreturned:2 reslen:119 locks:{ Global: { acquireCount: { r: 46124 } }, Database: { acquireCount: { r: 23062 } }, Collection: { acquireCount: { r: 23062 } } } 984ms
mongodb_1 | 2017-06-14T08:33:54.557+0000 I NETWORK [conn85] end connection 172.18.0.4:60128 (0 connections now open)
mongodb_1 | 2017-06-14T08:33:54.557+0000 I NETWORK [initandlisten] connection accepted from 172.18.0.4:60130 #86 (1 connection now open)
mongodb_1 | 2017-06-14T08:33:55.534+0000 I QUERY [conn86] query Info.info_b query: { geoname_id: 8223932 } planSummary: COLLSCAN ntoreturn:0 ntoskip:0 keysExamined:0 docsExamined:2951856 cursorExhausted:1 keyUpdates:0 writeConflicts:0 numYields:23061 nreturned:34 reslen:1746 locks:{ Global: { acquireCount: { r: 46124 } }, Database: { acquireCount: { r: 23062 } }, Collection: { acquireCount: { r: 23062 } } } 976ms
docker-compose:
version: '2'
services:
shmserver:
build:
context: ../
dockerfile: Dockerfile
ports:
- "18081:18081"
links:
- redis:redis
- mongodb:mongodb
depends_on:
- redis
- mongodb
redis:
image: redis:latest
volumes:
- /home/database:/var/lib/redis
ports:
- "6479:6379"
mongodb:
image: mongo
volumes:
- /home/db:/home/db
ports:
- "27017:27017"
command: --storageEngine wiredTiger --dbpath /home/db
怎么才能提升性能呢?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.