Giter VIP home page Giter VIP logo

info's Introduction

YNWA!

info's People

Contributors

gunyoung-kim avatar

Watchers

 avatar

info's Issues

성능 개선: 회원가입시 가입 환영 메일 발송 async/non-blocking으로 처리하기

Info 서비스에 회원 가입을 하게 되면 가입한 이메일로 Info 가입 환영 메일을 보내게 된다.

아래 코드는 소셜 로그인 회원의 가입을 처리하는 PersonController의 메소드다.

	@PostMapping(value="/oauth2/join") 
	public ModelAndView oAuth2Join(@ModelAttribute("formModel") @Valid OAuth2Join formModel) {
		if(isSessionUserEmailAndEmailInFormMisMatch(formModel.getEmail())) {
			throw new NotMyResourceException(PersonErrorCode.RESOURCE_IS_NOT_MINE_ERROR.getDescription());
		}
		Person person = getNewSavedPersonWithEncodedPassword(formModel);
		setNewAuthenticationInSecurityContext(person);
		sendEmailForJoin(formModel.getEmail());
		
		return new ModelAndView("redirect:/");
	}
	
  //(중략)

	private void sendEmailForJoin(String receiveMail) {
		EmailDTO email = EmailDTO.builder()
				.senderMail("[email protected]")
				.senderName("INFO")
				.receiveMail(receiveMail)
				.subject("INFO 가입을 환영합니다.")
				.message("INFO 가입을 굉장히 환영합니다.")
				.build();
		
		emailService.sendEmail(email);					
	}

sendEmailForJoin 메소드에서 가입 환영 메일을 보내는것이다.
메일 전송은 구글 메일 서버의 도움을 받았다.
근데 이 방식은 약간의 문제가 있다.

아래 로그는 회원 가입할때의 로그다.

info_main_async_2

개인 정보가 담겨있는 부분은 블라인드 처리했다. 물론 해당 회원의 동의를 얻고 해당 로그를 올리는 것이다. (해당 회원은 필자 본인이다..)
회원 가입 요청 처리가 다른 요청 처리 시간에 비해 3149ms 로 굉장히 요청처리 시간이 오래걸렸다.
실제로 회원가입하고 다음 화면(메인 화면)으로 넘어가는 시간이 꽤 길게 느껴졌다.
요청처리가 오래 걸리는 이유를 분석해본 결과 구글 메일서버를 통해 메일을 발송하는 부분에서 엄청난 시간 소비가 되는 것이었다. 그리고 만약에 구글 메일 서버와의 연동과정에서 문제가 생기면 클라이언트는 제대로 된 화면을 받지 못할 수도 있다.

문제 상황을 정리해보면 클라이언트 입장에서 회원가입하고나서 회원 가입 처리가 완료되었지만 메일 발송때문에 다음 화면으로 넘어가는데 꽤 지루한 시간을 기다려야 하는 것이다.

그래서 이에 대해 한가지 해결책을 생각해내었다.
바로 '비동기 처리'다
구글 메일 서버를 통해 메일을 전송하는 부분을 비동기로 처리하게 된다면 클라이언트 입장에선 회원가입 요청 후 다음 화면을 받기까지의 시간이 꽤 단축될 것이다.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.