Skip to content

Gyeom/infra-subway-performance

 
 

Repository files navigation

npm node Website GitHub


인프라공방 샘플 서비스 - 지하철 노선도


🚀 Getting Started

Install

npm 설치

cd frontend
npm install

frontend 디렉토리에서 수행해야 합니다.

Usage

webpack server 구동

npm run dev

application 구동

./gradlew clean build

미션

  • 미션 진행 후에 아래 질문의 답을 작성하여 PR을 보내주세요.

1단계 - 화면 응답 개선하기

요구사항

  • 부하테스트 각 시나리오의 요청시간을 목푯값 이하로 개선
    • 개선 전/후를 직접 계측하여 확인
  • Reverse Proxy 개선하기
  • WAS 성능 개선하기
  1. 성능 개선 결과를 공유해주세요 (Smoke, Load, Stress 테스트 결과) 프로젝트 monitoring 폴더에 올려놓았습니다.
  2. 어떤 부분을 개선해보셨나요? 과정을 설명해주세요
  • nginx gzip 압축, cache, HTTP/2 설정을 통해 Reverse Proxy를 개선했습니다.
  • redis를 이용하여 캐싱을 적용해 WAS 성능을 개선했습니다.

2단계 - 스케일 아웃

요구사항

  • springboot에 HTTP Cache, gzip 설정하기
  • Launch Template 작성하기
  • Auto Scaling Group 생성하기
  • Smoke, Load, Stress 테스트 후 결과를 기록
  1. Launch Template 링크를 공유해주세요.
  1. cpu 부하 실행 후 EC2 추가생성 결과를 공유해주세요. (Cloudwatch 캡쳐)
  • /monitoring/asg/cloudwatch/cloudwatch_asg.png
  1. 성능 개선 결과를 공유해주세요 (Smoke, Load, Stress 테스트 결과)
  • /monitoring/asg/smoke
  • /monitoring/asg/load
  • /monitoring/asg/stress
  1. 모든 정적 자원에 대해 no-cache, no-store 설정 가능한가요?

3단계 - 쿼리 최적화

  1. 인덱스 설정을 추가하지 않고 아래 요구사항에 대해 1s 이하(M1의 경우 2s)로 반환하도록 쿼리를 작성하세요.
  • 활동중인(Active) 부서의 현재 부서관리자 중 연봉 상위 5위안에 드는 사람들이 최근에 각 지역별로 언제 퇴실했는지 조회해보세요. (사원번호, 이름, 연봉, 직급명, 지역, 입출입구분, 입출입시간)
select ranker.employee_id as '사원번호', ranker.last_name as '이름', ranker.annual_income as '연봉', ranker.annual_income as '직급명', r.time as '입출입시간', r.region as '지역', r.record_symbol as '입출입구분'
from (
	select m.employee_id, dep.id, s.annual_income, e.last_name
	from (select d.id from department d where d.note = 'Active') dep
			inner join manager m on m.department_id = dep.id
			inner join salary s on s.id = m.employee_id
			inner join position p on p.position_name = 'Manager' and p.id = m.employee_id
			inner join employee e on e.id = m.employee_id
            where (m.start_date <= now() and m.end_date > now()) and (s.start_date <= now() and s.end_date > now()) and (p.start_date <= now() and p.end_date > now())
			order by s.annual_income desc
	limit 5
) ranker
inner join record r on r.record_symbol = 'O' and r.employee_id = ranker.employee_id 

4단계 - 인덱스 설계

요구사항

  1. 인덱스 적용해보기 실습을 진행해본 과정을 공유해주세요
  • Coding as a Hobby 와 같은 결과를 반환하세요.
    create index index_programmer_hobby
    on programmer (hobby);

    select hobby, round(count(*) / (select count(*) from programmer) * 100, 1) as rate
    from programmer
    group by hobby

explain1

  • 프로그래머별로 해당하는 병원 이름을 반환하세요. (covid.id, hospital.name)
    alter table hospital
    add constraint pk_hospital
    primary key (id);
    
    alter table covid
    add constraint pk_covid
    primary key (id);
    
    alter table programmer
    add constraint pk_programmer
    primary key (id);

    create index index_covid_hospital_id
    on covid (hospital_id);
    
    create index index_covid_programmer_id
    on covid (programmer_id);
    
    select c.id, h.name
    from hospital h
    inner join covid c on c.hospital_id = h.id
    inner join programmer p on p.id = c.programmer_id

explain2

  • 프로그래밍이 취미인 학생 혹은 주니어(0-2년)들이 다닌 병원 이름을 반환하고 user.id 기준으로 정렬하세요. (covid.id, hospital.name, user.Hobby, user.DevType, user.YearsCoding)
    create index index_hospital_name
    on hospital (name);

    select c.id, h.name, p.hobby, p.dev_type, p.years_coding
    from hospital h
    inner join covid c on c.hospital_id = h.id
    inner join programmer p on p.id = c.programmer_id
    where (p.hobby = 'Yes' and p.student in ('Yes, full-time', 'Yes, part-time')) or p.years_coding = '0-2 years'
    order by p.id

explain3

  • 서울대병원에 다닌 20대 India 환자들을 병원에 머문 기간별로 집계하세요. (covid.Stay)
    alter table member
    add constraint pk_member
    primary key (id);

    create index index_covid_stay
    on covid (stay);

    select c.stay, count(*) 
    from hospital h
    inner join covid c on c.hospital_id = h.id
    inner join programmer p on p.id = c.programmer_id
    inner join member m on m.id = p.id
    where h.name = '서울대병원' and m.age >= 20 and m.age < 30 and p.country = 'India'
    group by c.stay

explain4

  • 서울대병원에 다닌 30대 환자들을 운동 횟수별로 집계하세요. (user.Exercise)
    select p.exercise, count(*) 
    from hospital h
    inner join covid c on c.hospital_id = h.id
    inner join programmer p on p.id = c.programmer_id
    inner join member m on m.id = p.id
    where h.name = '서울대병원' and m.age >= 30 and m.age < 40
    group by p.exercise

explain5

추가 미션

  1. 페이징 쿼리를 적용한 API endpoint를 알려주세요
  1. replication 결과물 master slave

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 38.3%
  • SCSS 34.0%
  • Vue 19.8%
  • JavaScript 7.2%
  • Other 0.7%