Author Topic: gatling.io ปรับค่า connection ในการทำ load test  (Read 7835 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
gatling.io ปรับค่า connection ในการทำ load test
« on: ธันวาคม 14, 2015, 02:09:34 PM »
ตัว gatling สามารถทำ โหลดเทสได้ดีตัวหนึ่งครับ
ซึ่งเราสามารถเขียนเป็น scenario ให้เข้ากับระบบเว็บแอปของเราได้เลย จำลองเหมือนคนเข้ามาคลิกลิ้ง ทำการ search , ทำการ add/edit/delete ข้อมูล
และสามารถปรับจำนวน connection  ให้เสมือนว่ามีจำนวนคนเข้าเยอะ เป็นแต่ละ concurrent ได้ครับ

#example 1

setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)

atOnceUsers=1
เป็นการบอกให้ ทดสอบระบบโดยจำลอง user 1 connection ครับ
ถ้าต้องการจำนวน concurrent มากขึ้น ก็ปรับเป็นค่าที่มากกว่า 1 ได้เลยครับผม
« Last Edit: ธันวาคม 14, 2015, 02:55:31 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: gatling.io ปรับค่า connection
« Reply #1 on: ธันวาคม 14, 2015, 02:51:24 PM »
please simulate my whole scenario for 10 users in 30 seconds".
It basically means that our "users" will start interacting with our application progressively.
In this case, after 3 seconds a new user will start doing our flow.

setUp(
    scn.users(10).ramp(30).protocolConfig(httpConf)
)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: gatling.io ปรับค่า connection
« Reply #2 on: ธันวาคม 14, 2015, 02:53:01 PM »
Step 02: Configure virtual users
So, this is great, we can load test our server with... one user! Let’s increase the number of users.

Let’s define two populations of users:
regular users: they can search and browse computer models.
admin users: they can also edit computer models.
Translating into a scenario this gives:

val users = scenario("Users").exec(Search.search, Browse.browse)
val admins = scenario("Admins").exec(Search.search, Browse.browse, Edit.edit)
To increase the number of simulated users, all you have to do is to change the configuration of the simulation as follows:

setUp(users.inject(atOnceUsers(10)).protocols(httpConf))
Here we set only 10 users, because we don’t want to flood our test web application. Please, be kind and don’t crash our Heroku instance ;-)

If you want to simulate 3 000 users, you might not want them to start at the same time. Indeed, they are more likely to connect to your web application gradually.

Gatling provides the rampUsers builtin to implement this behavior. The value of the ramp indicates the duration over which the users will be linearly started.

In our scenario let’s have 10 regular users and 2 admins, and ramp them over 10 seconds so we don’t hammer the server:

setUp(
  users.inject(rampUsers(10) over (10 seconds)),
  admins.inject(rampUsers(2) over (10 seconds))
).protocols(httpConf)

#reference
http://gatling.io/docs/2.0.0-RC2/advanced_tutorial.html
« Last Edit: ธันวาคม 14, 2015, 02:55:45 PM by golfreeze »


golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: gatling.io ปรับค่า connection ในการทำ load test
« Reply #4 on: ธันวาคม 21, 2015, 01:06:46 PM »


เวลาเราจับ recorder.sh ใน gatling แล้วเจอพวกไฟล์รูป หรือ css เยอะ
ควรทำการ blacklist พวก รูปภาพ .jpg, .jpeg , .gif
หรือพวก .css , .js

โดยเปิด recorder.sh ขึ้นมาแล้วดูในส่วนของ Blacklist เลือกเป็น Strategy : Blacklist First
ถ้าจะเพิ่ม blacklist rule .jpg, .jpeg , .gif  กดเครื่องหมาย +
.*\.jpg
.*\.jpeg
.*\.gif
.*\.js
.*\.css

หรือจะทำการเพิ่มใน file .scala ลงไปเลยเป็น

.inferHtmlResources(BlackList(""".*\.js""", """.*\.css""", """.*\.jpg""", """.*\.JPG""", """.*\.gif""", """.*\.jpeg""", """.*\.ico""", """.*\.png""", """.*\.(t|o)tf""", """.*\.htc""", """DisplayExchangeRate"""), WhiteList())

แค่นี้แล้วทำการ ยิง gatling.sh ได้เลยครับ จัดหนักเลย
« Last Edit: ธันวาคม 21, 2015, 01:09:16 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: gatling.io ปรับค่า connection ในการทำ load test
« Reply #5 on: มกราคม 23, 2016, 06:30:27 PM »
การเชค througput gatling.io

Throughput คืออะไร

เป็นจำนวน transaction/request ที่ถูกสร้างขึ้นหรือทำงานได้ในช่วงเวลาการทดสอบหนึ่งๆ
ค่าใช้สำหรับบอกว่า ระบบงานมีความสามารถในการจัดการงานจำนวนเท่าไรในแต่ละหนึ่งหน่วยเวลานั้นๆ

สูตรการคำนวณนั้นไม่ยากเท่าไร นั่นก็คือ
Throughput   =  (จำนวน request หรือ transaction)   /   จำนวนเวลาการทำงานรวม

ก่อนเริ่มทำการทดสอบประสิทธิภาพ คุณจะต้องกำหนดเป้าหมาย
ในค่าของ Throughput  ไว้ก่อนเสมอ ว่าต้องการเท่าไร เช่น

จำนวนใน 1 วินาที
จำนวนใน 1 นาที
จำนวนใน 1 ชั่วโมง
ตัวอย่างเช่น

ระบบงานสามารถทำงานได้ 5 งานพร้อมๆ กันใน 1 นาที

ดังนั้น ถ้ามีงานเข้ามา 5 งานพร้อมๆ กัน
ระบบจะสามารถทำงานทั้ง 5 งานได้พร้อมๆ กัน โดยไม่มีงานใดรอเข้าทำงานเลย
แสดงว่าระบบงานมีค่า Throughput  = 5 ต่อ 1 นาที

หน่วยที่นิยมใช้สำหรับวัดค่า Throughput
นั่นก็คือ Transaction Per Second ( TPS )
นั่นคือจำนวน transaction ที่สามารถทำงานได้ใน 1 วินาที

ขอบคุณข้อมูลจาก : http://www.somkiat.cc/performance-testing-about-throughput/

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: gatling.io ปรับค่า connection ในการทำ load test
« Reply #6 on: กุมภาพันธ์ 04, 2016, 08:30:09 AM »
/* Feeder with csv file username,password */
/* user_information.csv */
username,password,account_id
user1,password1,4
user2,password2,7
...
user10,password10,34
/* Scenario */
.feed(csv("user_information.csv"))
.exec(
  http("request_3")
    .post("/login")
    .param("username", "${username}")
    .param("password", "${password}")
    .headers(headers_3)
    .check(status.is(302))
)
...
.exec(
  http("request_5")
    .get("/private/bank/account/ACC${account_id}/operations.html")
    .headers(headers_5)
)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: gatling.io ปรับค่า connection ในการทำ load test
« Reply #7 on: ตุลาคม 25, 2018, 07:09:16 PM »
host will get TPS = 6 x concurrent users / response time.