Skip to content

API 성능 테스트 및 쿼리 로그 정리

SeoSiun edited this page Aug 28, 2023 · 1 revision

API 요청시 실행되는 쿼리 로그 및 JMeter를 이용한 성능 테스트 결과를 정리한 문서입니다.


[GET] /agencies ➡️ gu에 index걸고 비교해보기

💬 Query Log

Hibernate:
    select
        agencyenti0_.id as id1_0_,
        agencyenti0_.gu as gu2_0_,
        agencyenti0_.latitude as latitude3_0_,
        agencyenti0_.longitude as longitud4_0_,
         agencyenti0_.name as name5_0_
    from
        agency agencyenti0_
    where
        agencyenti0_.gu=?

🏁 Test

📌 Request Param

  • gu: 성동구

✅ Test 1

스크린샷 2023-08-28 오후 3 48 54

✅ Test 2

스크린샷 2023-08-28 오후 3 49 19

[GET] /agencies/{agencyId}/car-masters

💬 Query Log

Hibernate:
    select
        carmastere0_.id as id1_3_0_,
        agencyenti1_.id as id1_0_1_,
        carmastere0_.agency_id as agency_i8_3_0_,
        carmastere0_.email as email2_3_0_,
        carmastere0_.img_url as img_url3_3_0_,
        carmastere0_.intro as intro4_3_0_,
        carmastere0_.name as name5_3_0_,
        carmastere0_.phone as phone6_3_0_,
        carmastere0_.sales as sales7_3_0_,
        agencyenti1_.gu as gu2_0_1_,
        agencyenti1_.latitude as latitude3_0_1_,
        agencyenti1_.longitude as longitud4_0_1_,
        agencyenti1_.name as name5_0_1_
    from
        car_master carmastere0_
    inner join
        agency agencyenti1_
            on carmastere0_.agency_id=agencyenti1_.id
    where
        agencyenti1_.id=?

🏁 Test

✅ Test 1 : 10

스크린샷 2023-08-28 오후 3 50 47

✅ Test 2 : 1000

스크린샷 2023-08-28 오후 3 51 52

[GET] /car-masters ➡️ 둘 중 어디서 오래걸리나? + 인덱스 걸어보기

💬 Query Log

Hibernate:
    SELECT
        a.*
    FROM
        agency a
    WHERE
        a.id IN (
            SELECT
                id
            FROM
                agency
            WHERE
                ST_Distance_Sphere(POINT(?, ?), POINT(longitude, latitude)) < 10000
        )
Hibernate:
    select
        carmastere0_.id as id1_3_0_,
        agencyenti1_.id as id1_0_1_,
        carmastere0_.agency_id as agency_i8_3_0_,
        carmastere0_.email as email2_3_0_,
        carmastere0_.img_url as img_url3_3_0_,
        carmastere0_.intro as intro4_3_0_,
        carmastere0_.name as name5_3_0_,
        carmastere0_.phone as phone6_3_0_,
        carmastere0_.sales as sales7_3_0_,
        agencyenti1_.gu as gu2_0_1_,
        agencyenti1_.latitude as latitude3_0_1_,
        agencyenti1_.longitude as longitud4_0_1_,
        agencyenti1_.name as name5_0_1_
    from
        car_master carmastere0_
    inner join
        agency agencyenti1_
            on carmastere0_.agency_id=agencyenti1_.id
    where
        agencyenti1_.id in (
            ? , ? , ?
        )
    order by
        carmastere0_.sales DESC,
        carmastere0_.name ASC

🏁 Test

📌 Request Param

  • latitude: 34.223123
  • longitude: 128.952979

✅ Test 1 : 10

스크린샷 2023-08-28 오후 3 53 03

✅ Test 2 : 1000

스크린샷 2023-08-28 오후 3 53 18

고민

  • Ramp-up period를 다 1로 설정하고 테스트했었는데, 10으로 늘려서 테스트하니까 같은 상황에서 훨씬 적은 시간이 걸렸다

    • ex) [POST] /estimates 에서 100, 10, 10 으로 설정하고 테스트하니까 27ms으로 줄었음

    ⇒ 내가 한 테스트가 의미 있는 것일까? 적절한 Thread property에 대해 고민해봐야할 것 같다.