대머리개발자

webFlux VS webMVC(준비) 본문

개발이야기/성능

webFlux VS webMVC(준비)

대머리개발자 2023. 2. 2. 16:18
728x90

로깅 서버를 통해서 이미 한번은 진행해 봤지만 또 해보자잉!

 

async, non-blocking에 대한 성능이 체감할 수 있을까??

 

부하툴 : ngrinder (https://naver.github.io/ngrinder/)

 

서버 Sepc. : Standard_D2s_v3 (azureprice.net)

 

Azure VM Comparison

 

azureprice.net

 

## 부하는 로컬에서 CPU와 메모리가 Full 차도록 줘보자!! 

## 테스트 시나리오

1. 인증코드를 받는다.

2. 인증코드를 통해서 토큰을 발급 받는다.

 

그루비 !!

@Test
    public void test() {
        HttpRequest request_code =  HttpRequest.get( "http://4.230.35.161/oauth/authorize?response_type=code&client_id=100000001&redirect_uri=http://localhost/calback")
        request_code.basic("2000021755", "O3os2WcHtMRqYoLtejSIMG5llP7oySTtG56QKKSDsJTwWwVH5V8jgFSxQqUAupQakzKWTvCoy4D+mU1jcemIGw==")
        if(request_code.ok()){
            def code = request_code.body()
            println "code : ${code}"
            HttpRequest request_token = HttpRequest.post( "http://4.230.35.161/oauth/token")
            def params = "code=${code}&grant_type=authorization_code&redirect_uri=http://localhost/calback&client_id=100000001&client_secret=AAFC0F6D50911302AE7EBD3ABBE9C96E"
            if(request_token.send(params).ok()){
                println request_token.body()
            }
        }
        println "Let's go home plz!!!"
    }

 

 

## 캐시 적용 (https://techblog.woowahan.com/2617/)

커스텀을 위해서 라이브러리를 그대로 사용한것은 아니라서 필요없는 일부분은 제외해서 블로그 만큼의 커넥션은 발생하지 않지만 그래도 오지게 커넥션 발생하기 때문에 캐시 적용.

@Around("execution(* oauth2.provider.client.JdbcClientDetailsService.loadClientByClientId(..))")
    public ClientDetails loadClientByClientId(ProceedingJoinPoint pjp) throws Throwable {
        Object[] args = pjp.getArgs();
        ...
        ClientDetails clientDetails = (ClientDetails)pjp.proceed();
        ...
        return clientDetails;
    }

 

## 리액티브 스타일이 너무 신선하다...쉬발!! ㅠ

    @Get("/oauth/authorize")
    public Mono<String> authorize(@Header("Authorization") String authorization, QueryParams params){
        if(!OAuth2Constants.CODE.equals(params.get(OAuth2Constants.RESPONSE_TYPE))) {
            throw new AuthorizationException(Constants.Exception.UNSUPPORTED_TYPE, "Unsupported types : "  + params.get(OAuth2Constants.RESPONSE_TYPE));
        }

       AuthorizationRequest authorizationRequest = AuthorizationRequest.builder().build();
       return getAuthenticationAndValidate(authorization)
                .flatMap(user -> {
                    authorizationRequest.setUser(user);                 // 사용자 정보
                    return getClientAndValidate(params);
                })
                .filter(client -> ObjectUtil.isEqualText(client.getRedirectUri(), params.get(OAuth2Constants.REDIRECT_URI)))
                .switchIfEmpty(Mono.error(new AuthorizationException(Constants.Exception.REDIRECT_MISMATCH, "A redirectUri must be either supplied or preconfigured in the Client")))
                .flatMap(client -> {
                    authorizationRequest.setClient(client);             // client 정보를 임시로 Save
                    return authorizationCodeServices.createAuthorizationCode(authorizationRequest);
                });

    }

맞게 하는건지 모른다..일단 고고

 

성능 테스트 조져 보자!!! 두구두구

728x90

'개발이야기 > 성능' 카테고리의 다른 글

이벤트 서버의 성능 테스트 시작(4)  (1) 2023.11.25
이벤트 서버의 성능 테스트 시작(3)  (1) 2023.11.23
webFlux VS webMVC(2)  (0) 2023.03.02
webFlux VS webMVC(1)  (0) 2023.02.09
로깅서버 성능 테스트  (1) 2022.10.07