๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Spring

๐Ÿ‘จ๐Ÿป‍๐Ÿ’ป Undertow ์ ์šฉํ•˜๊ธฐ (๋‹ค๋ฅธ WAS ์ ์šฉํ•ด๋ณด๊ธฐ)

๐Ÿ“Œ ์„œ๋ก 

SpringBoot๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด์„œ ๋‚ด์žฅ WAS๊ฐ€ ๋””ํดํŠธ๋กœ ์„ค์ •๋˜์–ด ์žˆ๋Š” Tomcat ์ด์™ธ์— ๋‹ค๋ฅธ WAS๋ฅผ ์‚ฌ์šฉํ•ด๋ณด๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์ด ๋‹ค์†Œ ์—†์—ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค.

SpringBoot ๊ด€๋ จ ์Šคํ„ฐ๋””๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ ์•„๋ž˜์™€ ๊ฐ™์€ ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ›์•˜๊ณ , ์ด๋ฒˆ ๊ธฐํšŒ์— ๋‹ค๋ฅธ WAS๋ฅผ ์ ์šฉํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค.


๐Ÿ“Œ Tomcat, Jetty, Netty, Undertow

Tomcat, Jetty, Netty๋Š” ์ž์„ธํžˆ๋Š” ๋ชฐ๋ผ๋„ ํ•œ ๋ฒˆ์”ฉ์€ ๋“ค์–ด๋ดค๋‹ค. ์‚ฌ์‹ค Undertow๋Š” ์ฒ˜์Œ ๋“ค์–ด๋ดค๋‹ค.

ํ”ผ๋“œ๋ฐฑ ์ค‘์— Undertow๋ฅผ ์™œ ์ ์šฉ ํ•ด๋ณด๋ผ๊ณ  ํ•˜๋Š” ๊ฒƒ์ผ๊นŒ? ๋ผ๋Š” ์ƒ๊ฐ๊ณผ, Tomcat ๋ณด๋‹ค ์žฅ์ ์ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด์ง€ ์•Š์„๊นŒ? ๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.

๊ทธ๋ž˜์„œ ๊ทธ๋ƒฅ ์‚ฌ์šฉํ•˜๊ธฐ ๋ณด๋‹ค ๋‹ค๋ฅธ ์„ ํƒ์ง€๋“ค์„ ๋น„๊ตํ•˜๋ฉฐ ์‚ฌ์šฉํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค.

Tomcat

  • ์ปค๋ฎค๋‹ˆํ‹ฐ๊ฐ€ ํ™œ๋ฐœํ•˜๋ฉฐ, ์ž๋ฐ” ์ง„์˜์—์„œ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋˜๊ณ  ์žˆ๋Š” WAS์ด๋‹ค.
  • ์Šคํ”„๋ง๋ถ€ํŠธ์—์„œ ๊ธฐ๋ณธ ๋‚ด์žฅ WAS๋กœ ์„ค์ •๋˜์–ด ์žˆ๋‹ค.
  • Tomcat์„ ์„œ๋น„์Šค์— ์‚ฌ์šฉํ•˜๊ธฐ์— ๋ฌด๋ฆฌ๊ฐ€ ์žˆ๋‹ค๊ณ  ํ•˜๋Š” ๊ฐœ๋ฐœ์ž๋„ ๋ณด์ธ๋‹ค.
  • Tomcat 8.5๋ถ€ํ„ฐ ์ข‹์•„์กŒ๋‹ค๊ณ  ํ•˜์ง€๋งŒ ์—ฌ์ „ํžˆ ๋ฌธ์ œ์ ์ด ์กด์žฌํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์ธ๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์ด Tomcat์„ ๋”ฐ๋กœ ์ถ”๊ฐ€ํ•˜์ง€ ์•Š์•„๋„ ๊ธฐ๋ณธ์ ์œผ๋กœ Tomcat์ด ์„ค์ •๋œ๋‹ค.

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
</dependency>

 

implementation('org.springframework.boot:spring-boot-starter-web')

Jetty

  • ์ ์€ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ€๋ณ๊ณ , ๋น ๋ฅด๋‹ค.
  • ๊ฒฝ๋Ÿ‰ WAS๋ผ๊ณ ๋„ ๋ถˆ๋ฆฐ๋‹ค.
  • ๊ทœ๋ชจ๊ฐ€ ์žˆ๋Š” ํ”„๋กœ์ ํŠธ์— ์ ์šฉํ•˜๊ธฐ์—” ๋ฌด๋ฆฌ๊ฐ€ ์žˆ์ง€๋งŒ, ์ž์‹ ์˜ ์ƒํ™ฉ์— ๋งž๊ฒŒ ์„ ํƒํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
		</exclusion>
	</exclusions>
</dependency>

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

 

implementation('org.springframework.boot:spring-boot-starter-web') {
	exclude module: 'spring-boot-starter-tomcat'
}
implementation('org.springframework.boot:spring-boot-starter-jetty')

Netty

  • Async, Event-Driven ๋ฐฉ์‹์˜ ๋„คํŠธ์›Œํฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ํ”„๋ ˆ์ž„์›Œํฌ์ด๋‹ค.
  • Netty๋Š” Spring WebFlux์—์„œ ๊ธฐ๋ณธ ๋‚ด์žฅ WAS์œผ๋กœ ์ œ๊ณต๋œ๋‹ค.
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>

 

implementation('org.springframework.boot:spring-boot-starter-webflux')

Undertow

  • JBoss๋Š” J2EE ๊ทœ๊ฒฉ์„ ๋ชจ๋‘ ๋งŒ์กฑํ•˜๋Š” WAS๋ฅผ ์ œ๊ณตํ•˜๋Š”๋ฐ ์ตœ๊ทผ Tomcat์„ ๋ฒ„๋ฆฌ๊ณ  Netty๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ Undertow๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค.
  • Undertow๋ฅผ ๊ณต์‹ ๋ฌธ์„œ์—์„œ ์•„๋ž˜์™€ ๊ฐ™์ด ์†Œ๊ฐœํ•˜๊ณ  ์žˆ๋‹ค.
    • blocking๊ณผ non-blocking ๋ชจ๋‘ ์‚ฌ์šฉ๋˜๋„๋ก ์„ค๊ณ„๋œ ์›น ์„œ๋ฒ„์ด๋‹ค. ์ฃผ์š” ๊ธฐ๋Šฅ์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.
      • High Performance
      • Embeddable
      • Servlet 4.0
      • Web Sockets
      • Reverse Proxy
  • ๋Œ€๊ทœ๋ชจ ํŠธ๋ž˜ํ”ฝ์œผ๋กœ๋ถ€ํ„ฐ Tomcat๋ณด๋‹ค ์•ˆ์ •์ ์ด๋ผ๊ณ  ํ‰๊ฐ€๋ฅผ ๋ฐ›๊ณ  ์žˆ๋‹ค.
  • ๋ฒค์น˜๋งˆํฌ ํ…Œ์ŠคํŠธ์—์„œ ์•ˆ์ •์„ฑ์„ ์ฆ๋ช…ํ•œ ์‚ฌ๋ก€๊ฐ€ ๋งŽ์ด ๋ณด์ด๊ณ  ์žˆ๋‹ค. (Tomcat๊ณผ Undertow ๋น„๊ต)

org.springframework.boot.autoconfigure.web.servlet์—์„œ ServletWebServerFactoryAutoConfiguration.java ๋ฅผ ์—ด์–ด๋ณด๋ฉด

์•„๋ž˜์™€ ๊ฐ™์ด SpringBoot๋Š” Tomcat, Jetty์™€ ๋”๋ถˆ์–ด Undertow๋ฅผ ๋‚ด์žฅ WAS๋กœ ์‰ฝ๊ฒŒ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๊ฒŒ ์ง€์›ํ•˜๊ณ  ์žˆ๋‹ค.

...
@Import({ServletWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar.class, EmbeddedTomcat.class, EmbeddedJetty.class, EmbeddedUndertow.class})
public class ServletWebServerFactoryAutoConfiguration {
...

๐Ÿ“Œ Undertow ์ ์šฉํ•˜๊ธฐ

๋น„๊ตํ•˜๊ณ  ๋ณด๋‹ˆ ๋””ํดํŠธ๋กœ ์ œ๊ณตํ•˜๋Š” Tomcat๋ณด๋‹ค Undertow๊ฐ€ ๋” ๋‚ซ๋‹ค๊ณ  ์ƒ๊ฐ์ด ๋“ ๋‹ค.
(Spring WebFlux์—์„œ ๊ธฐ๋ณธ ๋‚ด์žฅ WAS๋ฅผ Netty๋กœ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์„ ๋ณด๋ฉด, Tomcat์˜ ์‹œ๋Œ€๋Š” ์ง€๋‚˜์ง€ ์•Š์„๊นŒ..?)

Undertow๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค์ •ํ•˜๋ฉด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
		</exclusion>
	</exclusions>
</dependency>

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>

 

implementation('org.springframework.boot:spring-boot-starter-web') {
	exclude module: 'spring-boot-starter-tomcat'
}
implementation('org.springframework.boot:spring-boot-starter-undertow')

 

๊ตฌ๋™ ๋ชจ์Šต

Tomcat ์ ์šฉ
Undertow ์ ์šฉ


๐Ÿ“Œ ์ฐธ๊ณ  ์ž๋ฃŒ

 

Undertow

There are two ways to end an exchange, either by fully reading the request channel, and calling shutdownWrites() on the response channel and then flushing it, or by calling HttpServerExchange.endExchange(). When endExchange() is called Undertow will check

undertow.io

 

Spring Boot ๊ณต์‹ ์ง€์› ๋‚ด์žฅ WAS ์ธ Undertow ์„ ์”์‹œ๋‹ค.

Java ๊ฐ€ Web ๊ฐœ๋ฐœ์—์„œ ๋‘๊ฐ์„ ๋‚˜ํƒ€๋‚ด๋ฉด์„œ WAS(Web Application Server) ๋ผ๋Š” ์šฉ์–ด๋ฅผ ๋„๋ฆฌ ์‚ฌ์šฉํ•˜๊ฒŒ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒ˜์Œ์˜ ์˜๋„์™€ ๋‹ฌ๋ฆฌ WAS ์„ ์ง€์นญํ•˜๋Š” ์˜๋ฏธ๋Š” ์ ์ฐจ ํ™•๋Œ€๋˜์—ˆ๊ณ , Java ์—์„œ๋Š” Apache Tomcat(์ดํ•˜ T

zepinos.tistory.com

 

Undertow ์™€ Tomcat ์˜ ๊ฐ„๋‹จํ•œ ๋น„๊ต

2019/01/23 - [Programming/Java] - Spring Boot ๊ณต์‹ ์ง€์› ๋‚ด์žฅ WAS ์ธ Undertow ์„ ์”์‹œ๋‹ค. ์ด์ „์— Spring Boot ์—์„œ Embedded Tomcat ๋Œ€์‹ ์— Undertow ์„ ์‚ฌ์šฉํ•˜์ž๊ณ  ๊ธ€์„ ์ž‘์„ฑํ•œ ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ธ€์˜ ๋‚ด์šฉ์—..

zepinos.tistory.com

 

Spring Boot ๋‚ด์žฅ WAS ์ข…๋ฅ˜์™€ ํŠน์ง•

์Šคํ”„๋ง ๋ถ€ํŠธ ๋‚ด์žฅ WAS์˜ ์ข…๋ฅ˜์™€ ํŠน์ง•์ž…๋‹ˆ๋‹ค. ์ตœ๋Œ€ํ•œ ์‰ฝ๊ฒŒ ์ ์–ด๋ดค์–ด์š”. Tomcat ~7๋ฒ„์ „๊นŒ์ง€ ๋Œ€๊ทœ๋ชจ ํŠธ๋ž˜ํ”ฝ์—์„œ ๋ถˆ์•ˆ์ •ํ•˜๋‹ค vs ์•„๋‹ˆ๋‹ค ๋“ฑ์˜ ์˜๊ฒฌ์ด ๋ถ„๋ถ„ํ–ˆ๊ณ , 8๋ฒ„์ „์€ ํญ๋งํ–ˆ์ง€๋งŒ, 8.5๋ฒ„์ „์œผ๋กœ ๋Œ€์‘ํ•˜์—ฌ

gofnrk.tistory.com

 

JBOSS

์˜คํ”ˆ์†Œ์Šค ๋ฏธ๋“ค์›จ์–ด – ์ œ์ด๋ณด์Šค(JBoss) ์ œ์ด๋ณด์Šค(JBoss)๋Š” ์ž๋ฐ”๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๋Š” ์˜คํ”ˆ ์†Œ์Šค ๋ฏธ๋“ค์›จ์–ด์˜ ์ด์นญ์œผ๋กœ, ๋Œ€ํ‘œ์ ์œผ๋กœ๋Š” Java EE ์ŠคํŽ™์„์ง€์›ํ•˜๋Š” ์ œ์ด๋ณด์Šค ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„๊ฐ€ ์žˆ๋‹ค. Ja

creator0609.tistory.com