'2012/10'에 해당되는 글 2건

  1. 2012.10.25 maven으로 의존 lib들과 함께 java application package 방법
  2. 2012.10.09 apache ab


maven으로 의존 lib들과 함께 java application package 방법


java application package 방법


1. executable jar with dependencies

=> 의존 lib들을 .class 파일로 하나의 jar 파일 안에 package 


# maven-assembly-plugin

- 의존 lib들중 menifest (namespace) 파일이 겹치는 경우 가장 마지막 것만 남음


			<plugin>

				<groupId>org.apache.maven.plugins</groupId>

				<artifactId>maven-assembly-plugin</artifactId>

				<version>2.2.1</version>

				<configuration>

					<descriptorRefs>

						<descriptorRef>jar-with-dependencies</descriptorRef>

					</descriptorRefs>

					<archive>

						<manifest>

							<mainClass>com.stewie.test.Main</mainClass>

						</manifest>

					</archive>

				</configuration>

				<executions>

					<execution>

						<phase>package</phase>

						<goals>

							<goal>assembly</goal>

						</goals>

					</execution>

				</executions>

			</plugin>


# maven-shade-plugin

- 설정으로 manifest 파일을 append하여 namespace 문제 해결 가능


<예제>

			<plugin>

				<groupId>org.apache.maven.plugins</groupId>

				<artifactId>maven-shade-plugin</artifactId>

				<version>1.7.1</version>

				<executions>

					<execution>

						<phase>package</phase>

						<goals>

							<goal>shade</goal>

						</goals>

						<configuration>

							<transformers>

								<transformer

									implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">

									<mainClass>com.stewie.test.Main</mainClass>

								</transformer>

								<transformer

									implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">

									<resource>properties.properties</resource>

								</transformer>

								<transformer

									implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">

									<resource>applicationContext.xml</resource>

								</transformer>

							</transformers>

						</configuration>

					</execution>

				</executions>

			</plugin>



2. /${dist}.jar , /lib, /bin 형태의 tar로 package 방법


# maven-assembly-plugin 사용


		<plugins>

			<plugin>

				<artifactId>maven-assembly-plugin</artifactId>

				<executions>

					<execution>

						<id>distribution-assembly</id>

						<phase>package</phase>

						<goals>

							<goal>single</goal>

						</goals>

						<configuration>

							<descriptors>

								<descriptor>assembly/assembly.xml</descriptor>

							</descriptors>

							<finalName>${filename}</finalName>

							<appendAssemblyId>false</appendAssemblyId>

						</configuration>

					</execution>

				</executions>

			</plugin>

		</plugins>

- 필요한 descriptor 예시 (참조 : http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html)


<?xml version="1.0" encoding="UTF-8"?>

<assembly

	xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"

	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

	xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

	<id>zip</id>

	<formats>

		<format>tar</format>

	</formats>

	<includeBaseDirectory>false</includeBaseDirectory>



	<dependencySets>

		<dependencySet>

			<includes>

				<include>.....</include>

        ..

        ..

			</includes>

			<outputDirectory>lib</outputDirectory>

			<unpack>false</unpack>

		</dependencySet>

	</dependencySets>

	<fileSets>

		<fileSet>

			<directory>${basedir}</directory>

			<outputDirectory>/</outputDirectory>

			<includes>

				<include>**/*.jar</include>

			</includes>

		</fileSet>

	</fileSets>

</assembly>


// 사족으로 moduleset은 생각보다 작동이 션찮다

신고
Posted by Stewie

apache ab

07.Web 2012.10.09 09:27

apache ab는 벤치마크 툴로서 서버 및 웹 어플리케이션의 성능 측정에 사용된다.

가장 많이 쓰여지는 옵션은 -t, -c, -n 정도 인 것 같다.


심심해서 http://www.naver.com 으로 테스트를 해봤다.


$ ab -t 10 -c 10 http://www.naver.com/

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Copyright 2006 The Apache Software Foundation, http://www.apache.org/


Benchmarking www.naver.com (be patient)

Finished 410 requests



Server Software:        nginx

Server Hostname:        www.naver.com

Server Port:            80


Document Path:          /

Document Length:        109954 bytes


Concurrency Level:      10

Time taken for tests:   10.5510 seconds

Complete requests:      410

Failed requests:        408

   (Connect: 0, Length: 408, Exceptions: 0)

Write errors:           0

Total transferred:      44177669 bytes

HTML transferred:       44040476 bytes

Requests per second:    40.98 [#/sec] (mean)

Time per request:       244.037 [ms] (mean)

Time per request:       24.404 [ms] (mean, across all concurrent requests)

Transfer rate:          4311.82 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:       12   30 208.9     16    3014

Processing:   115  202 295.1    144    3664

Waiting:       15   27 148.3     20    3021

Total:        131  233 364.9    160    3685


Percentage of the requests served within a certain time (ms)

  50%    160

  66%    167

  75%    174

  80%    180

  90%    441

  95%    491

  98%    544

  99%   3161

 100%   3685 (longest request)


역시 예상했던 것 처럼 nginx를 사용중이다.

실제 업무에서 사용해보진 못했지만 httpd 수준으로 알아둬야겠다.

신고
Posted by Stewie


티스토리 툴바