微軟的Garnet的安裝學習以及與Redis的簡單對比
安裝方式
官網上面其實沒有寫如何安裝garnet的
很多人見識用nuget的方式進行安裝
我這邊簡單嘗試了下也沒看出來怎麼用exe
沒辦法 只能學習 dockerfile 裏面的內容在windows上面進行編譯.
下載地址
https://codeload.github.com/microsoft/garnet/tar.gz/refs/tags/v1.0.0
需要注意裏面的內容由多個 DOCKFILE 是很好的指導文件
需要再次說明的事,garnet 是基於.net開發的程序
編譯必須有dotnet sdk 運行應該至少有 dotnet 的 runtime
爲了簡單期間, 這邊都使用 dotnet sdk的方式
下載地址爲:
https://dotnet.microsoft.com/zh-cn/download/dotnet/8.0
編譯安裝
必須先安裝 dotnet sdk
然後查看 tar.gz 包裏面的dockfile進行學習
Linux上面的爲:
WORKDIR /source/main/GarnetServer
RUN dotnet publish -c Release -o /app --self-contained false -f net8.0
Windows上面的爲:
WORKDIR /source/main/GarnetServer
RUN dotnet publish -c Release -o /app -r win-x64 --self-contained false -f net8.0
下載好tar包之後, 進入目錄比如我這邊:
C:\Users\Administrator\Downloads\garnet-1.0.0\main\GarnetServer
直接執行命令:
RUN dotnet publish -c Release -o /app -r win-x64 --self-contained false -f net8.0
會在:C:\app 產生安裝文件, 二進制的文件爲:GarnetServer.exe
注意配置文件的模板爲:
C:\Users\Administrator\Downloads\garnet-1.0.0\libs\host\defaults.conf
比較重要的需要改的參數有:
"Port" : 3278,
"AuthenticationMode" : "Password",
"Password" : "Yourpassword",
注意複製過來之後,直接修改就可以了
執行命令爲: 在 C:\app 執行
GarnetServer.exe --config-import-path garnet.conf
注意我本地的配置文件就是: C:\app\garnet.conf
可以使用 redis-cli 進行鏈接
也可以使用 redis-benchmark 進行簡單測試.
需要說明我下面的對比是 redisWin7.0.5 的版本和 Garnet1.0.0的版本
Redis-benchmark
測試項目 |
garnet on windows |
時延 |
redis on Windows |
時延 |
PING_INLINE |
41876 |
0.612 |
56465 |
0.638 |
PING_MBULK |
42034 |
0.610 |
58685 |
0.475 |
SET |
40128 |
0.643 |
55005 |
0.735 |
GET |
41050 |
0.626 |
55617 |
0.528 |
INCR |
42936 |
0.603 |
55865 |
0.593 |
LPUSH |
43159 |
0.600 |
54141 |
0.651 |
SADD |
40306 |
0.637 |
53163 |
0.801 |
HSET |
42354 |
0.608 |
57770 |
0.704 |
總結
garnet的時延好像的確表優秀一點
但是跟redis比 他的吞吐量感覺還是稍微差一些.
可能是我選擇的benchmark工具有問題, 但是也說明了一些問題.
garnet 還是需要優化的. 不知道產品兼容性如何.