[問題] local machine vs server: mongodb
前輩們好,
小弟剛學python幾個月, 想問個一直困擾我很久的問題
我有一個function
內容大概是
def sortdata:
connect to mongodb
get all document in a collection with find()
iterate over the collection and make a dictionary out of the result
return the dictionary
我如果用電腦跑的話整個過程大概要15秒左右
但同樣的function我把它弄成server (用flask, deploy到heroku)
然後寫一個get route 讓這個function最後return json然後吐一個response object
我在我的電腦丟一個http request來取得sortdata的結果
這個卻可以秒完成 (約一秒吧? 或兩秒)
請問為什麼會這樣呢?
找了找stackoverflow沒看到什麼類似的解答
我也不知道這個問題是不是太廣 如果是的話還請各位前輩指點一些關鍵字
讓我可以自己去慢慢查看..
謝謝
--
○ ○ ◢█████◣ ○ ○ ○
○ ██◤◤◤◤▎ ○ ○
○ ◢█◥██⊙–⊙▏ 炸你全家!!!
██████皿█ ▄▄▄▄▄▄▄ 崖上のboyo
○ ◢█∕█◥██︶◤◤ ○ ○ ○
▂▅▄▆▇ by Airsupply
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.45.124
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1490877518.A.760.html
※ 編輯: jn8029 (140.112.45.124), 03/30/2017 20:39:18
→
03/30 22:05, , 1F
03/30 22:05, 1F
→
03/31 00:21, , 2F
03/31 00:21, 2F
→
03/31 00:21, , 3F
03/31 00:21, 3F