Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
55 changes: 47 additions & 8 deletions src/test/scala/encry/Explorer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,61 @@ package encry
import io.gatling.core.Predef._
import io.gatling.core.structure.ChainBuilder
import io.gatling.http.Predef._
import io.gatling.http.request.builder.HttpRequestBuilder

import scala.concurrent.duration._

object Explorer {

def getIndex: ChainBuilder = {
def transactionsScenario: ChainBuilder = {
exec(
http("Index")
.get("/")
http("transaction list")
.get("/transactions?page=0")
.check(
status is 200
status is 200,
regex("href=\"/transaction/(.*?)\"").findAll.saveAs("transIds")
)
)
).pause(800 millis, 1000 millis)
.exec(visitRandomTrans("unconfTransaction")).pause(800 millis, 1000 millis)
.exec(visitRandomTrans("unconfTransaction")).pause(800 millis, 1000 millis)
.exec(visitRandomTrans("unconfTransaction")).pause(800 millis, 1000 millis)
}

def visitRandomTrans(name: String): HttpRequestBuilder = {
http(name)
.get("/transaction/${transIds.random()}")
.check(status is 200)
}

def blocksScenario: ChainBuilder = {
exec(
http("block list")
.get(s"/")
.check(
status is 200,
regex("href=\"/block/(.*?)\"").findAll.saveAs("blockIds")
)
).pause(800 millis, 1000 millis)
.exec(http("block")
.get("/block/${blockIds.random()}")
.check(
status is 200,
regex("href=\"/transaction/(.*?)\"").findAll.saveAs("transIds")
)
).pause(800 millis, 1000 millis)
.exec(visitRandomTrans("transaction")).pause(800 millis, 1000 millis)
.exec(visitRandomTrans("transaction")).pause(800 millis, 1000 millis)
.exec(visitRandomTrans("transaction")).pause(800 millis, 1000 millis)
}

val scenario: ChainBuilder =
def nodesScenario: ChainBuilder = {
exec(
getIndex
http("node list")
.get("/node")
.check(
status is 200
)
)
}

}
}
11 changes: 7 additions & 4 deletions src/test/scala/encry/ExplorerSim.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ class ExplorerSim extends Simulation {

val httpProtocol = http
.baseUrl("http://172.16.11.20:9000") // Here is the root for all relative URLs
//.baseUrl("http://192.168.0.105:9000") // Here is the root for all relative URLs
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.5")
.userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")

// A scenario is a chain of requests and pauses
val scn = scenario("Explorer").exec(Explorer.scenario)
val scn = scenario("Explorer").exec(Explorer.transactionsScenario, Explorer.blocksScenario, Explorer.nodesScenario)

setUp(scn.inject(
atOnceUsers(1)
)
.protocols(httpProtocol))
//atOnceUsers(1)
//constantUsersPerSec(1).during(60 seconds)
rampUsersPerSec(10).to(25).during(100 seconds)
//rampUsers(3000).during(100 seconds)
).protocols(httpProtocol))
}
99 changes: 99 additions & 0 deletions target/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Stress Test</title>
</head>
<body>

<p>
MSI-notebook<br>
Intel(R) Core(TM) i5-4210H CPU @ 2.90GHz * 4 core<br>
RAM: 8Gb<br>
SSD<br>
PostgreSQL DB included<br><br>

CPU load: 100%<br><br>

Cuncurent users comfortable use: 400 CU<br>
Cuncurent users uncomfortable use: 400-500 CU<br><br>

</p>

<a href="./notebook/1 user/index.html" target="_blank">1 user</a><br><br>

<a href="./notebook/rampUsers(1000).during(100 seconds)/index.html" target="_blank">rampUsers(1000).during(100 seconds)</a><br><br>

<a href="./notebook/rampUsers(1500).during(100 seconds)/index.html" target="_blank">rampUsers(1500).during(100 seconds)</a><br><br>

<a href="./notebook/rampUsers(2000).during(100 seconds)/index.html" target="_blank">rampUsers(2000).during(100 seconds)</a><br><br>

<a href="./notebook/rampUsers(3000).during(100 seconds)/index.html" target="_blank">rampUsers(3000).during(100 seconds)</a><br><br>

<a href="./notebook/rampUsersPerSec(10).to(25).during(100 seconds)/index.html" target="_blank">rampUsersPerSec(10).to(25).during(100 seconds)</a><br><br>

<a href="./notebook/rampUsersPerSec(15).to(25).during(100 seconds)/index.html" target="_blank">rampUsersPerSec(15).to(25).during(100 seconds)</a><br><br>

<a href="./notebook/rampUsersPerSec(15).to(30).during(100 seconds)/index.html" target="_blank">rampUsersPerSec(15).to(30).during(100 seconds)</a><br><br>

<a href="./notebook/rampUsersPerSec(20).to(35).during(100 seconds)/index.html" target="_blank">rampUsersPerSec(20).to(35).during(100 seconds)</a><br><br><br>

<a href="./notebook/rampUsers(5000).during(100 seconds) Trans/index.html" target="_blank">rampUsers(5000).during(100 seconds) Transactions only</a><br><br>

<a href="./notebook/rampUsers(8000).during(100 seconds) Trans 5000tx/index.html" target="_blank">rampUsers(8000).during(100 seconds) Transactions only 5000tx</a><br><br>

<a href="./notebook/rampUsers(9000).during(100 seconds) Trans 9000tx/index.html" target="_blank">rampUsers(9000).during(100 seconds) Transactions only 10000tx</a><br><br>

<a href="./notebook/rampUsers(10000).during(100 seconds) Trans 8000tx/index.html" target="_blank">rampUsers(10000).during(100 seconds) Transactions only 8000tx</a><br>

<p>
Cuncurent users comfortable use: 800 CU<br>
Cuncurent users uncomfortable use: 800-1000 CU<br>
</p>

<a href="./notebook/rampUsersPerSec(15).to(30).during(100 seconds) Block +/index.html" target="_blank">rampUsersPerSec(15).to(30).during(100 seconds) Blocks only</a><br><br>

<a href="./notebook/rampUsers(3000).during(100 seconds) Block/index.html" target="_blank">rampUsers(3000).during(100 seconds) Blocks only</a><br><br>

<a href="./notebook/rampUsersPerSec(20).to(35).during(100 seconds) Block/index.html" target="_blank">rampUsersPerSec(20).to(35).during(100 seconds) Blocks only</a><br><br>

<p>
testnet10: 172.16.11.20<br>
Intel(R) Xeon(R) CPU @ 2.10GHz<br>
RAM: 4Gb<br>
PostgreSQL DB dedicated<br><br>

CPU load: 30-50%<br><br>

Cuncurent users comfortable use: 200 CU<br>
Cuncurent users uncomfortable use: 200-300 CU<br>

</p>

<a href="./node20/rampUsersPerSec(10).to(15).during(100 seconds)/index.html" target="_blank">rampUsersPerSec(10).to(25).during(100 seconds)</a><br><br>

<a href="./node20/rampUsersPerSec(5).to(10).during(100 seconds)/index.html" target="_blank">rampUsersPerSec(5).to(10).during(100 seconds)</a><br><br><br>

<a href="./node20/rampUsersPerSec(20).to(35).during(100 seconds) Trans/index.html" target="_blank">rampUsersPerSec(20).to(35).during(100 seconds) Transactions only</a><br><br>

<a href="./node20/rampUsersPerSec(20).to(50).during(100 seconds) Trans/index.html" target="_blank">rampUsersPerSec(20).to(50).during(100 seconds) Transactions only</a><br><br>

<a href="./node20/rampUsersPerSec(20).to(80).during(100 seconds) Trans/index.html" target="_blank">rampUsersPerSec(20).to(80).during(100 seconds) Transactions only</a><br><br><br>

<a href="./node20/rampUsersPerSec(5).to(15).during(100 seconds) Block/index.html" target="_blank">rampUsersPerSec(5).to(15).during(100 seconds) Blocks only</a><br><br>

<a href="./node20/rampUsersPerSec(10).to(25).during(100 seconds) Block/index.html" target="_blank">rampUsersPerSec(10).to(25).during(100 seconds) Blocks only</a><br><br>

<p>
Оптимизация:<br>
Основная нагрузка приходится на БД, инфа из памяти запрашивается в 3-6 раз быстрее чем из базы ( unconfTransaction - из памяти / transaction - из базы )<br>
- оптимизировать запрос транзакции из базы (transaction), TransactionsDao.getFullTransaction, сейчас происходит 4 запроса к базе, готовить данные что бы доставать одним запросом.<br>
- держать в памяти последних n блоков, для быстрого доступа<br>
- сделать paging для транзакций внутри блока<br>
</p>

---------------------<br><br>
<a href="https://github.com/EncryFoundation/ExplorerLoadTest" target="_blank">github: Gatling ExplorerLoadTest</a><br><br>

</body>
</html>
Loading