在 Tarantool 中,您可以將超高速數據庫和應用程序結合起來使用它們。 這是多麼容易做到

五年前,我嘗試使用 Tarantool,但後來它對我不起作用。 但最近我舉辦了一次網絡研討會,其中我談論了 Hadoop,以及 MapReduce 的工作原理。 有人問我這樣的問題:“為什麼不使用 Tarantool 來完成這項任務?”。

出於好奇,我決定返回它,測試最新版本 - 這次我真的很喜歡這個項目。 現在我將展示如何在 Tarantool 中編寫一個簡單的應用程序,加載它並檢查性能,您將看到那裡的一切是多麼簡單和酷。

在 Tarantool 中,您可以將超高速數據庫和應用程序結合起來使用它們。 這是多麼容易做到

什麼是塔蘭圖爾

Tarantool 將自己定位為超快數據庫。 您可以將任何您想要的數據放在那裡。 另外,複製它們、分片——即將大量數據分割到多個服務器上並合併它們的結果——建立容錯的主主鏈接。

其次,它是一個應用服務器。 您可以在其上編寫應用程序,處理數據,例如,根據某些規則在後台刪除舊條目。 您可以直接在 Tarantula 中編寫一個處理數據的 Http 服務器:給出它們的編號,在那裡寫入新數據並將其全部歸結為一個主數據。

我讀過一篇關於這些人如何製作 300 行消息隊列的文章,它只是撕裂和顛簸 - 他們的最低性能為每秒 20 條消息。 在這裡你真的可以轉身編寫一個非常大的應用程序,並且這些不會被存儲,就像在PostgreS中一樣。

大約有這樣一個服務器,只是簡單而已,我將在本文中嘗試描述。

安裝

為了進行測試,我啟動了三個標準虛擬機 - 一個 20 GB 硬盤、Ubuntu 18.04。 2 個虛擬 CPU 和 4 GB 內存。

我們安裝 Tarantool - 運行 bash 腳本或添加存儲庫並執行 apt get install Tarantool。 鏈接到腳本 - (curl -L https://tarantool.io/installer.sh | VER=2.4 sudo -E bash)。 我們有這樣的命令:

塔蘭圖爾克特爾 是管理 Tarantula 實例的主要命令。
/etc/tarantool - 這是整個配置。
var/log/tarantool - 這是日誌。
var/lib/tarantool - 這裡存放數據,然後將它們劃分為實例。

有實例可用和實例啟用文件夾 - 它包含將啟動的內容 - 帶有 lua 代碼的實例配置文件,它描述了它偵聽的端口、可用的內存、Vinyl 引擎設置、啟動時工作的代碼服務器、分片、隊列、刪除過時數據等。

實例的工作方式與 PostgreS 中類似。 例如,您想要運行掛在不同端口上的數據庫的多個副本。 事實證明,在一台服務器上啟動了多個數據庫實例,這些實例掛在不同的端口上。 它們可以具有完全不同的設置 - 一個實例實現一種邏輯,第二個實例實現另一種邏輯。

實例管理

我們有 tarantoolctl 命令,它允許我們管理 Tarantula 實例。 例如,tarantoolctl check example 將檢查配置文件,如果沒有語法錯誤,則表示文件正常。

您可以查看實例的狀態 - tarantoolctl status example。 以同樣的方式,您可以執行啟動、停止、重新啟動。

實例運行後,有兩種方法可以連接到它。

1. 管理控制台

默認情況下,Tarantool 打開一個套接字並發送純 ASCII 文本來控制 Tarantula。 與控制台的連接始終發生在admin用戶下,沒有身份驗證,因此您不需要取出控制台端口來控制外面的Tarantula。

要以這種方式連接,您需要輸入 Tarantoolctl 輸入實例名稱。 該命令將啟動控制台並以管理員用戶身份進行連接。 切勿將控制台端口暴露在外 - 最好將其保留為單元插座。 然後,只有那些對套接字具有寫訪問權限的人才能連接到狼蛛。

行政事務需要此方法。 要處理數據,請使用第二種方法 - 二進制協議。

2. 使用二進制協議連接到特定端口

配置中有一個listen指令,它打開外部通信的端口。 該端口與二進制協議一起使用,並在此處啟用身份驗證。

對於此連接,使用 tarantoolctl 連接到端口號。 使用它,您可以連接到遠程服務器,使用身份驗證並授予各種訪問權限。

數據記錄和盒子模塊

由於Tarantool既是數據庫又是應用服務器,因此它具有各種模塊。 我們對盒子模塊感興趣 - 它實現了數據處理。 當您向盒子寫入內容時,Tarantool 會將數據寫入磁盤、將其存儲在內存中或對其執行其他操作。

記錄

例如,我們進入 box 模塊並調用 box.once 函數。 當服務器初始化時,它將強制 Tarantool 運行我們的代碼。 我們創建一個存儲數據的空間。

local function bootstrap()
    local space = box.schema.create_space('example')
    space:create_index('primary')
    box.schema.user.grant('guest', 'read,write,execute', 'universe')

    -- Keep things safe by default
    --  box.schema.user.create('example', { password = 'secret' })
    --  box.schema.user.grant('example', 'replication')
    --  box.schema.user.grant('example', 'read,write,execute', 'space', 'example')
end

之後,我們創建一個主索引(primary),通過它我們可以搜索數據。 默認情況下,如果未指定參數,則將使用引物索引的每個條目中的第一個字段。

然後我們向來賓用戶授予權限,在該權限下我們通過二進制協議進行連接。 我們允許在整個實例中讀取、寫入和執行。

與傳統數據庫相比,這裡的一切都非常簡單。 我們有空間——一個簡單存儲數據的區域。 每個條目稱為一個元組。 它被打包在 MessagePack 中。 這是一種非常酷的格式 - 它是二進制的,佔用的空間更少 - 18 字節與 27 字節相比。

在 Tarantool 中,您可以將超高速數據庫和應用程序結合起來使用它們。 這是多麼容易做到

和他一起工作很方便。 幾乎每一行、每個數據條目都可以有完全不同的列。

我們可以使用 Box.space 命令查看所有空間。 要選擇特定實例,我們編寫 box.space 示例並獲取有關它的完整信息。

Tarantool 內置了兩種類型的引擎:Memory 和 Vinyl。 內存將所有數據存儲在內存中。 因此,一切都簡單而快速地進行。 數據轉儲到磁盤,並且還有預寫日誌機制,因此如果服務器崩潰我們不會丟失任何內容。

Vinyl 以更熟悉的形式將數據存儲在磁盤上 - 也就是說,您可以存儲比我們內存更多的數據,而 Tarantula 將從磁盤讀取它。

現在我們將使用內存。

unix/:/var/run/tarantool/example.control> box.space.example
---
- engine: memtx
  before_replace: 'function: 0x41eb02c8'
  on_replace: 'function: 0x41eb0568'
  ck_constraint: []
  field_count: 0
  temporary: false
  index:
    0: &0
      unique: true
      parts:
      - type: unsigned
        is_nullable: false
        fieldno: 1
      id: 0
      space_id: 512
      type: TREE
      name: primary
    primary: *0
  is_local: false
  enabled: true
  name: example
  id: 512
...

unix/:/var/run/tarantool/example.control>

指數:

必須為任何空間創建主索引,因為沒有它什麼都無法工作。 與在任何數據庫中一樣,我們創建第一個字段 - 記錄 ID。

零件:

這是我們指定索引的組成部分的地方。 它由一個部分組成 - 我們將使用的第一個字段,類型為無符號 - 一個正整數。 據我所記得的文檔,最大數量是 18 quintillion。 很多很棒的。

然後我們可以使用插入命令插入數據。

unix/:/var/run/tarantool/example.control> box.space.example:insert{1, 'test1', 'test2'}
---
- [1, 'test1', 'test2']
...

unix/:/var/run/tarantool/example.control> box.space.example:insert{2, 'test2', 'test3', 'test4'}
---
- [2, 'test2', 'test3', 'test4']
...

unix/:/var/run/tarantool/example.control> box.space.example:insert{3, 'test3'}
---
- [3, 'test3']
...

unix/:/var/run/tarantool/example.control> box.space.example:insert{4, 'test4'}
---
- [4, 'test4']
...

unix/:/var/run/tarantool/example.control>

第一個字段用作主鍵,因此它必須是唯一的。 我們不受列數的限制,因此我們可以插入任意數量的數據。 它們以 MessagePack 格式指定,正如我上面所描述的。

數據輸出

然後我們可以使用 select 命令顯示數據。

Box.example.select 使用鍵 {1} 將顯示所需的條目。 如果我們省略密鑰,我們將看到我們擁有的所有記錄。 它們的列數都不同,但這裡原則上不存在列的概念 - 有字段編號。

您想要多少數據就可以有多少數據。 例如,我們需要在第二個字段中搜索它們。 為此,我們創建一個新的二級索引。


box.space.example:create_index( ‘secondary’, { type = ‘TREE’, unique = false, parts = {{field = 2, type =’string’} }}) 

我們使用 Create_index 命令。
我們稱之為次要的。

之後,您需要指定參數。 索引類型是TREE。 它可能不是唯一的,因此我們輸入 Unique = false。

然後我們指出我們的索引由哪些部分組成。 Field 是我們綁定索引的字段號,並指定字符串類型。 它就這樣被創建了。

unix/:/var/run/tarantool/example.control> box.space.example:create_index('secondary', { type = 'TREE', unique = false, parts = {{field = 2, type = 'string'}}})
---
- unique: false
  parts:
  - type: string
    is_nullable: false
    fieldno: 2
  id: 1
  space_id: 512
  type: TREE
  name: secondary
...

unix/:/var/run/tarantool/example.control>

現在我們可以這樣稱呼它:

unix/:/var/run/tarantool/example.control> box.space.example.index.secondary:select('test1')
---
- - [1, 'test1', 'test2']
...

保存

如果我們重新啟動實例並嘗試再次調用數據,我們將看到它們不在那裡 - 一切都是空的。 發生這種情況是因為Tarantool 會創建檢查點並將數據保存到磁盤,但如果我們在下一次保存之前停止工作,我們將丟失所有操作- 因為我們將從上一個檢查點(例如,兩個小時前)恢復。

節省每一秒也行不通——因為不斷地將 20 GB 轉儲到磁盤是一個馬馬虎虎的想法。

為此,發明並實現了預寫日誌的概念。 在它的幫助下,對於數據的每次更改,都會在小型預寫日誌文件中創建一條記錄。

直到檢查點的每個條目都存儲在其中。 對於這些文件,我們設置大小 - 例如 64 mb。 當它填滿時,錄音開始進入第二個文件。 重啟後,Tarantool 從上一個檢查點恢復,然後滾動所有後續事務,直到停止。

在 Tarantool 中,您可以將超高速數據庫和應用程序結合起來使用它們。 這是多麼容易做到

要執行這樣的記錄,您需要在 box.cfg 設置中指定一個選項(在 example.lua 文件中):

wal_mode = “write”;

數據使用

通過我們現在編寫的內容,您可以使用 Tarantula 來存儲數據,並且它將作為數據庫運行得非常快。 現在是蛋糕上的櫻桃 - 您可以用這一切做什麼。

編寫應用程序

例如,讓我們為狼蛛編寫這樣一個應用程序

請參閱劇透下方的應用程序

box.cfg {
    listen = '0.0.0.0:3301';
    io_collect_interval = nil;
    readahead = 16320;
    memtx_memory = 128 * 1024 * 1024; -- 128Mb
    memtx_min_tuple_size = 16;
    memtx_max_tuple_size = 128 * 1024 * 1024; -- 128Mb
    vinyl_memory = 128 * 1024 * 1024; -- 128Mb
    vinyl_cache = 128 * 1024 * 1024; -- 128Mb
    vinyl_max_tuple_size = 128 * 1024 * 1024; -- 128Mb
    vinyl_write_threads = 2;
    wal_mode = "write";
    wal_max_size = 256 * 1024 * 1024;
    checkpoint_interval = 60 * 60; -- one hour
    checkpoint_count = 6;
    force_recovery = true;
    log_level = 5;
    log_nonblock = false;
    too_long_threshold = 0.5;
    read_only   = false
}

local function bootstrap()
    local space = box.schema.create_space('example')
    space:create_index('primary')

    box.schema.user.create('example', { password = 'secret' })
    box.schema.user.grant('example', 'read,write,execute', 'space', 'example')

    box.schema.user.create('repl', { password = 'replication' })
    box.schema.user.grant('repl', 'replication')
end

-- for first run create a space and add set up grants
box.once('replica', bootstrap)

-- enabling console access
console = require('console')
console.listen('127.0.0.1:3302')

-- http config
local charset = {}  do -- [0-9a-zA-Z]
    for c = 48, 57  do table.insert(charset, string.char(c)) end
    for c = 65, 90  do table.insert(charset, string.char(c)) end
    for c = 97, 122 do table.insert(charset, string.char(c)) end
end

local function randomString(length)
    if not length or length <= 0 then return '' end
    math.randomseed(os.clock()^5)
    return randomString(length - 1) .. charset[math.random(1, #charset)]
end

local http_router = require('http.router')
local http_server = require('http.server')
local json = require('json')

local httpd = http_server.new('0.0.0.0', 8080, {
    log_requests = true,
    log_errors = true
})

local router = http_router.new()

local function get_count()
 local cnt = box.space.example:len()
 return cnt
end

router:route({method = 'GET', path = '/count'}, function()
    return {status = 200, body = json.encode({count = get_count()})}
end)

router:route({method = 'GET', path = '/token'}, function()
    local token = randomString(32)
    local last = box.space.example:len()
    box.space.example:insert{ last + 1, token }
    return {status = 200, body = json.encode({token = token})}
end)

prometheus = require('prometheus')

fiber = require('fiber')
tokens_count = prometheus.gauge("tarantool_tokens_count",
                              "API Tokens Count")

function monitor_tokens_count()
  while true do
    tokens_count:set(get_count())
    fiber.sleep(5)
  end
end
fiber.create(monitor_tokens_count)

router:route( { method = 'GET', path = '/metrics' }, prometheus.collect_http)

httpd:set_router(router)
httpd:start()

我們在 lua 中聲明一些定義符號的表。 需要該表來生成隨機字符串。

local charset = {}  do -- [0-9a-zA-Z]
    for c = 48, 57  do table.insert(charset, string.char(c)) end
    for c = 65, 90  do table.insert(charset, string.char(c)) end
    for c = 97, 122 do table.insert(charset, string.char(c)) end
end

之後,我們聲明一個函數 - randomString 並在括號中給出長度值。

local function randomString(length)
    if not length or length <= 0 then return '' end
    math.randomseed(os.clock()^5)
    return randomString(length - 1) .. charset[math.random(1, #charset)]
end

然後我們將 http 路由器和 http 服務器連接到我們的 Tarantula 服務器 JSON,我們將把它提供給客戶端。

local http_router = require('http.router')
local http_server = require('http.server')
local json = require('json')

之後,我們從所有 http 服務器接口上的端口 8080 啟動,這將記錄所有請求和錯誤。

local httpd = http_server.new('0.0.0.0', 8080, {
    log_requests = true,
    log_errors = true
})

接下來,我們聲明一條路由,如果使用 GET 方法的請求到達端口 8080 /count,則我們從一行調用該函數。 它返回一個狀態 - 200、404、403 或我們指定的任何狀態。

router:route({method = 'GET', path = '/count'}, function()
    return {status = 200, body = json.encode({count = get_count()})}
end)

在正文中,我們返回 json.encode,我們在其中指定 count 和 getcount,這將被調用並顯示數據庫中的記錄數。

第二種方法

router:route({method = 'GET', path = '/token'}, function() 
    local token = randomString(32) 
    local last = box.space.example:len() 
    box.space.example:insert{ last + 1, token } 
    return {status = 200, body = json.encode({token = token})}
end)

在哪裡排隊 路由器:路由({方法='GET',路徑='/令牌'},函數() 我們調用該函數並生成一個令牌。

弦樂 本地令牌 = randomString(32) 是一個 32 個字符的隨機字符串。
排隊 本地最後 = box.space.example:len() 我們取出最後一個元素。
並在行中 box.space.example:insert{ 最後 + 1, 標記 } 我們將數據寫入數據庫,也就是說,我們只需將 ID 加 1。順便說一下,這不僅可以通過如此笨拙的方式來完成。 狼蛛有這種情況的序列。

我們在那裡寫令牌。

因此,我們在一個文件中編寫了一個應用程序。 您可以立即訪問數據,盒子模塊將為您完成所有臟活。

它監聽 http 並處理數據,一切都在一個實例中 - 應用程序和數據。 因此,一切都發生得很快。

要運行,我們安裝 http 模塊:

我們是如何做到的,請參閱劇透下方

root@test2:/# tarantoolctl rocks install http
Installing http://rocks.tarantool.org/http-scm-1.src.rock
Missing dependencies for http scm-1:
   checks >= 3.0.1 (not installed)

http scm-1 depends on checks >= 3.0.1 (not installed)
Installing http://rocks.tarantool.org/checks-3.0.1-1.rockspec

Cloning into 'checks'...
remote: Enumerating objects: 28, done.
remote: Counting objects: 100% (28/28), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 28 (delta 1), reused 16 (delta 1), pack-reused 0
Receiving objects: 100% (28/28), 12.69 KiB | 12.69 MiB/s, done.
Resolving deltas: 100% (1/1), done.
Note: checking out '580388773ef11085015b5a06fe52d61acf16b201'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

No existing manifest. Attempting to rebuild...
checks 3.0.1-1 is now installed in /.rocks (license: BSD)

-- The C compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found TARANTOOL: /usr/include (found version "2.4.2-80-g18f2bc82d")
-- Tarantool LUADIR is /.rocks/share/tarantool/rocks/http/scm-1/lua
-- Tarantool LIBDIR is /.rocks/share/tarantool/rocks/http/scm-1/lib
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    version


-- Build files have been written to: /tmp/luarocks_http-scm-1-V4P9SM/http/build.luarocks
Scanning dependencies of target httpd
[ 50%] Building C object http/CMakeFiles/httpd.dir/lib.c.o
In file included from /tmp/luarocks_http-scm-1-V4P9SM/http/http/lib.c:32:0:
/tmp/luarocks_http-scm-1-V4P9SM/http/http/lib.c: In function ‘tpl_term’:
/usr/include/tarantool/lauxlib.h:144:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
    (*(B)->p++ = (char)(c)))
    ~~~~~~~~~~~^~~~~~~~~~~~
/tmp/luarocks_http-scm-1-V4P9SM/http/http/lib.c:62:7: note: in expansion of macro ‘luaL_addchar’
       luaL_addchar(b, '\');
       ^~~~~~~~~~~~
/tmp/luarocks_http-scm-1-V4P9SM/http/http/lib.c:63:6: note: here
      default:
      ^~~~~~~
In file included from /tmp/luarocks_http-scm-1-V4P9SM/http/http/lib.c:39:0:
/tmp/luarocks_http-scm-1-V4P9SM/http/http/tpleval.h: In function ‘tpe_parse’:
/tmp/luarocks_http-scm-1-V4P9SM/http/http/tpleval.h:147:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
    type = TPE_TEXT;
    ~~~~~^~~~~~~~~~
/tmp/luarocks_http-scm-1-V4P9SM/http/http/tpleval.h:149:3: note: here
   case TPE_LINECODE:
   ^~~~
In file included from /tmp/luarocks_http-scm-1-V4P9SM/http/http/lib.c:40:0:
/tmp/luarocks_http-scm-1-V4P9SM/http/http/httpfast.h: In function ‘httpfast_parse’:
/tmp/luarocks_http-scm-1-V4P9SM/http/http/httpfast.h:372:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
                 code = 0;
                 ~~~~~^~~
/tmp/luarocks_http-scm-1-V4P9SM/http/http/httpfast.h:374:13: note: here
             case status:
             ^~~~
/tmp/luarocks_http-scm-1-V4P9SM/http/http/httpfast.h:393:23: warning: this statement may fall through [-Wimplicit-fallthrough=]
                 state = message;
                 ~~~~~~^~~~~~~~~
/tmp/luarocks_http-scm-1-V4P9SM/http/http/httpfast.h:395:13: note: here
             case message:
             ^~~~
[100%] Linking C shared library lib.so
[100%] Built target httpd
[100%] Built target httpd
Install the project...
-- Install configuration: "Debug"
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/VERSION.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lib/http/lib.so
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/server/init.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/server/tsgi_adapter.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/nginx_server/init.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/router/init.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/router/fs.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/router/matching.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/router/middleware.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/router/request.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/router/response.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/tsgi.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/utils.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/mime_types.lua
-- Installing: /.rocks/share/tarantool/rocks/http/scm-1/lua/http/codes.lua
http scm-1 is now installed in /.rocks (license: BSD)

root@test2:/#

我們還需要 prometheus 來運行:

root@test2:/# tarantoolctl rocks install prometheus
Installing http://rocks.tarantool.org/prometheus-scm-1.rockspec

Cloning into 'prometheus'...
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 19 (delta 2), reused 5 (delta 0), pack-reused 0
Receiving objects: 100% (19/19), 10.73 KiB | 10.73 MiB/s, done.
Resolving deltas: 100% (2/2), done.
prometheus scm-1 is now installed in /.rocks (license: BSD)

root@test2:/#

我們啟動並可以訪問模塊

root@test2:/# curl -D - -s http://127.0.0.1:8080/token
HTTP/1.1 200 Ok
Content-length: 44
Server: Tarantool http (tarantool v2.4.2-80-g18f2bc82d)
Connection: keep-alive

{"token":"e2tPq9l5Z3QZrewRf6uuoJUl3lJgSLOI"}

root@test2:/# curl -D - -s http://127.0.0.1:8080/token
HTTP/1.1 200 Ok
Content-length: 44
Server: Tarantool http (tarantool v2.4.2-80-g18f2bc82d)
Connection: keep-alive

{"token":"fR5aCA84gj9eZI3gJcV0LEDl9XZAG2Iu"}

root@test2:/# curl -D - -s http://127.0.0.1:8080/count
HTTP/1.1 200 Ok
Content-length: 11
Server: Tarantool http (tarantool v2.4.2-80-g18f2bc82d)
Connection: keep-alive

{"count":2}root@test2:/#

/count 給我們狀態 200。
/token 發出一個令牌並將該令牌寫入數據庫。

測試速度

讓我們運行 50 個請求的基準測試。 競爭性請求將為 000。

root@test2:/# ab -c 500 -n 50000 http://127.0.0.1:8080/token
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Completed 50000 requests
Finished 50000 requests


Server Software:        Tarantool
Server Hostname:        127.0.0.1
Server Port:            8080

Document Path:          /token
Document Length:        44 bytes

Concurrency Level:      500
Time taken for tests:   14.578 seconds
Complete requests:      50000
Failed requests:        0
Total transferred:      7950000 bytes
HTML transferred:       2200000 bytes
Requests per second:    3429.87 [#/sec] (mean)
Time per request:       145.778 [ms] (mean)
Time per request:       0.292 [ms] (mean, across all concurrent requests)
Transfer rate:          532.57 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   10 103.2      0    3048
Processing:    12   69 685.1     15   13538
Waiting:       12   69 685.1     15   13538
Total:         12   78 768.2     15   14573

Percentage of the requests served within a certain time (ms)
  50%     15
  66%     15
  75%     16
  80%     16
  90%     16
  95%     16
  98%     21
  99%     42
 100%  14573 (longest request)
root@test2:/#

代幣已發行。 我們不斷記錄數據。 99% 的請求在 42 毫秒內完成。 因此,在一台有 3500 個核心和 2 GB 內存的小型機器上,我們每秒大約有 4 個請求。

您還可以選擇一些 50000 代幣並查看其價值。

您不僅可以使用 http,還可以運行處理數據的後台函數。 另外還有各種觸發器。 例如,您可以在更新時調用函數、檢查某些內容 - 修復衝突。

您可以直接在數據庫服務器本身中編寫腳本應用程序,而不受任何限制,連接任何模塊並實現任何邏輯。

應用程序服務器可以訪問外部服務器、收集數據並將其添加到其數據庫中。 該數據庫中的數據將被其他應用程序使用。

這將由狼蛛本身完成,無需編寫單獨的應用程序。

總之

這只是一項重大工作的第一部分。 第二個將很快發佈在 Mail.ru Group 博客上,我們一定會在本材料中添加指向它的鏈接。

如果您有興趣參加我們在線創建這些東西並實時提出問題的活動,請連接到 REBRAIN 頻道的 DevOps.

如果您需要遷移到雲端或對您的基礎架構有疑問, 請隨時提交請求.

PS 我們每月有 2 次免費審核,也許您的項目就是其中之一。

來源: www.habr.com

添加評論