2010년 4월 초에  Tomcat Race Condtion 에 대한 버그 리포트와 Patch가 올라왔습니다. https://issues.apache.org/bugzilla/show_bug.cgi?id=48843

 

이 문제는 리퀘스트가 많이 나타날 수 있는 Critical 버그로서, 동시성 관련된 문제(Race Condition)입니다. AJP 뿐 아니라 NIO, JIO 까지 관련된 문제입니다.

 

문제가 된 코드는 다음과 같습니다.

요청을 받으면 톰캣의 WorkerThread를 하나 얻어오도록 합니다. Worker thread가 없으면 대기하고, 있으면 Worker Thread를 리턴합니다.

(Consumer-Producer의 전형적인 코드입니다. )

 

protected Worker getWorkerThread(){

...

Worker workerThread = createWorkerThread();

        while (workerThread == null) {

            try {

                synchronized (workers) {

                    workers.wait();

                 }

            }

...

}

 

내부 Worker 쓰레드 내용

protected class Worker implements Runnable {

….

private synchronized Socket await() {

// Wait for the Connector to provide a new Socket

         while (!available) {

                 try {

                     wait();

                  } catch (InterruptedException e) {

                  }

          }

 

          // Notify the Connector that we have received this Socke

        Socket socket = this.socket;

          available = false;

          notifyAll();

return (socket);

}

 

 

만약 Request 쓰레드가 2일 때를 가정했을 때 (maxThread=2), Request 쓰레드와 Acceptor 쓰레드간의 Race condition 상황에서 재현될 수 있습니다.

 

1.     Acceptor 쓰레드가 workerThread null인 상태에서 “while 를 통과하였습니다.

2.     요청을 완료한 Request 쓰레드가 recycleWorkerThread()를 실행하고 나서, Worker.await()메소드에서 연결 요청을 받기 위해서 wait() 메소드에서 대기하고 있습니다.

3.     Acceptor 쓰레드가 workers.wait() 메소드에서 무한 대기를 합니다.

 

서로 깨워주지(notify) 못한 채, 연결 요청을 처리해 주지 못하게 됩니다.

 

<수정사항>

AJP, NIO, JIO EndPointer가 수정되었습니다.

 

protected Worker getWorkerThread() {

         // Allocate a new worker thread

-        Worker workerThread = createWorkerThread();

-        while (workerThread == null) {

-            try {

-                synchronized (workers) {

+        synchronized (workers) {

+            Worker workerThread;

+            while ((workerThread = createWorkerThread()) == null) {

+                try {

                     workers.wait();

+                } catch (InterruptedException e) {

+                    // Ignore

                 }

-            } catch (InterruptedException e) {

-                // Ignore

             }

-            workerThread = createWorkerThread();

+            return workerThread;

         }

-        return workerThread;

     }

 

 

<웹 영향도>

추후 최신 버전으로 패치 버전을 받아 업그레이드를 해야 함.

하지만, maxThreads 디폴트가 200 이므로, 아주 Critical 이슈는 없을 것으로 생각됨..

 

 


'Web service' 카테고리의 다른 글

Tomcat Major 패치 (5.5.29, 6.0.27) - 파일 다운로드 관련  (0) 2010.04.12
톰캣 7 개발 도구  (0) 2010.04.12
AJP 연결 테스트 (AJP command line client)  (0) 2010.04.05
Reverse Proxy  (0) 2010.04.05
쓸만한 플래쉬  (0) 2010.03.19
Posted by '김용환'
,


https://issues.apache.org/bugzilla/show_bug.cgi?id=47242

Tomcat 개발진 중 하나가 AJP 연결 테스트 코드를 개발하였다..
참고할 것.

'Web service' 카테고리의 다른 글

톰캣 7 개발 도구  (0) 2010.04.12
Tomcat 버그 패치 (Race Condition)  (0) 2010.04.06
Reverse Proxy  (0) 2010.04.05
쓸만한 플래쉬  (0) 2010.03.19
IBatis - Oscache 연동  (0) 2010.02.22
Posted by '김용환'
,

Reverse Proxy

Web service 2010. 4. 5. 14:59

수많은 웹 서버군의 영문서에 자주 나오는 말인데, 개발자중에서는 이 말을 잘 쓰는 사람이 없어서.. 써본다.

이 단어의 의미는 웹 서버의 앞단 Proxy 서버를 의미한다.

Load balancing도 하고, 네트웍 연결에 대해서 처리해주기도 하는 물리(논리) 서버를 총칭해서 의미한다.

아파치 모듈도 이런 이름으로 가진 것이 있다.

참고 http://en.wikipedia.org/wiki/Reverse_proxy




'Web service' 카테고리의 다른 글

Tomcat 버그 패치 (Race Condition)  (0) 2010.04.06
AJP 연결 테스트 (AJP command line client)  (0) 2010.04.05
쓸만한 플래쉬  (0) 2010.03.19
IBatis - Oscache 연동  (0) 2010.02.22
img 태그의 onerror 처리 관련  (0) 2010.02.11
Posted by '김용환'
,

쓸만한 플래쉬

Web service 2010. 3. 19. 18:58



http://flare.prefuse.org/apps/dependency_graph

dependency를 플래쉬로 보여줄 때, 좋을 것 같다..
Graph, Tree, Map 괜찮은듯..











'Web service' 카테고리의 다른 글

AJP 연결 테스트 (AJP command line client)  (0) 2010.04.05
Reverse Proxy  (0) 2010.04.05
IBatis - Oscache 연동  (0) 2010.02.22
img 태그의 onerror 처리 관련  (0) 2010.02.11
Java script go back reload  (0) 2010.02.09
Posted by '김용환'
,




## ibatis configuration
<cacheModel type="OSCACHE" id="MainContent"> 
    <flushInterval seconds="300"/> 
    <flushOnExecute statement="com.google.dummy"/>
</cacheModel> 

## oscache.properties

cache.capacity=1000

참고 :  http://www.opensymphony.com/oscache/wiki/Configuration.html




## 자세한 내용은 밑의 참조
http://pupustory.tistory.com/188

'Web service' 카테고리의 다른 글

Reverse Proxy  (0) 2010.04.05
쓸만한 플래쉬  (0) 2010.03.19
img 태그의 onerror 처리 관련  (0) 2010.02.11
Java script go back reload  (0) 2010.02.09
Apache MPM event  (0) 2010.02.08
Posted by '김용환'
,

'Web service' 카테고리의 다른 글

쓸만한 플래쉬  (0) 2010.03.19
IBatis - Oscache 연동  (0) 2010.02.22
Java script go back reload  (0) 2010.02.09
Apache MPM event  (0) 2010.02.08
아파치 설정 - if/else then  (0) 2009.08.18
Posted by '김용환'
,


미리 미리 알았어야 하는데.

<input type="button" value="Reload Page" onClick="window.location.reload()">


<input type="button" value="go back" onClick="history.go(-1)">

'Web service' 카테고리의 다른 글

IBatis - Oscache 연동  (0) 2010.02.22
img 태그의 onerror 처리 관련  (0) 2010.02.11
Apache MPM event  (0) 2010.02.08
아파치 설정 - if/else then  (0) 2009.08.18
두 form을 한 줄로 보여주기  (0) 2009.07.15
Posted by '김용환'
,

Apache MPM event

Web service 2010. 2. 8. 13:11


http://httpd.apache.org/docs/2.2/mod/event.html

아파치에 MPM event라는 것이 있었다. 확인을 해보니. 정식 버젼은 아니지만.
Keep alive 문제에 대한 고민, 해결 철학이 들어가 있다.

요청과 Keep Alive한 아파치 요청을 그대로 맺는 것이 아니라, 요청을 처리하는 쓰레드를 따로 두도록 하여 분산된 처리를 할 수 있게 하는데 목적을 둔 것 같다.


This MPM tries to fix the 'keep alive problem' in HTTP. After a client completes the first request, the client can keep the connection open, and send further requests using the same socket. This can save signifigant overhead in creating TCP connections. However, Apache traditionally keeps an entire child process/thread waiting for data from the client, which brings its own disadvantages. To solve this problem, this MPM uses a dedicated thread to handle both the Listening sockets, and all sockets that are in a Keep Alive state.

The MPM assumes that the underlying apr_pollset implementation is reasonably threadsafe. This enables the MPM to avoid excessive high level locking, or having to wake up the listener thread in order to send it a keep-alive socket. This is currently only compatible with KQueue and EPoll.



 SSL과 연동되지 않는 다는 단점. 그리고, 어떻게 방향이 이끌어갈지는 모르겠으나..
일반적으로 그냥 apache 자체성능 관점에서는 기존의 아파치보다는 성능이 많이 좋다라는 테스트가 진행되었다..  (내가 직접 한 테스트가 아니라서 자세히 모름. )

'Web service' 카테고리의 다른 글

img 태그의 onerror 처리 관련  (0) 2010.02.11
Java script go back reload  (0) 2010.02.09
아파치 설정 - if/else then  (0) 2009.08.18
두 form을 한 줄로 보여주기  (0) 2009.07.15
[Java script] How to glue two forms  (0) 2009.06.23
Posted by '김용환'
,

아파치에서 if else와 같은 문은 다음과 같이 사용하면 된다. (L을 이용한다)
다음은 L7check.jsp가 들어오면, 해당 URL을 보여주고, 아니면, / 로 이동하는 것이다. 
(보안상 jsp로 직접 들어오는 경우를 막는다..)

  RewriteRule  ^/L7check.jsp$ /L7check.jsp  [L]
  RewriteRule  ^/aa.jsp(.*) /aa.jsp$1  [L]
  RewriteCond  %{REQUEST_URI} ^(.*)\.jsp$
  RewriteRule  / $1 [NC,R]
  RewriteRule     ^/$                  /index.html      [PT,L]
  RewriteRule     ^$                   /index.html      [PT,L]

'Web service' 카테고리의 다른 글

Java script go back reload  (0) 2010.02.09
Apache MPM event  (0) 2010.02.08
두 form을 한 줄로 보여주기  (0) 2009.07.15
[Java script] How to glue two forms  (0) 2009.06.23
How to support UTF-8 URIEncoding with Tomcat  (0) 2009.06.15
Posted by '김용환'
,

기본적으로 두개의 form을 연달아 쓰면, 붙여쓸 수 없다.
이에 대해서 div를 쓰면, form 두개를 연달아 쓸 수 있다.


  <td norwap align=center>
   <div id="row1" style="float:left;">
    <form method="get" action="/oracle/dbprop.nhn" name="form" style="width: 21px;">
     <fieldset>
      <input type="hidden" name="m" value="updateuserui" />
      <input type="hidden" name="sid" value="${con.sid}"/>
      <input type="hidden" name="user_id" value="${con.user_id}"/>
      <input type="image" src="/images/modify.jpg" onmousedown="this.form.m.value='updateuserui'" />
     </fieldset>
    </form>
   </div>
   <div id="row2" style="float:left;">
    <form method="get" action="/oracle/dbprop.nhn" name="form" style="width: 21px;">
     <fieldset>
      <input type="hidden" name="m" value="deleteuser" />
      <input type="hidden" name="sid" value="${con.sid}"/>
      <input type="hidden" name="user_id" value="${con.user_id}"/>
      <input type="image" src="/common/images/remove.gif" onmousedown="this.form.m.value='deleteuser'" />
     </fieldset>
    </form>  
   </div>
  </td>

'Web service' 카테고리의 다른 글

Apache MPM event  (0) 2010.02.08
아파치 설정 - if/else then  (0) 2009.08.18
[Java script] How to glue two forms  (0) 2009.06.23
How to support UTF-8 URIEncoding with Tomcat  (0) 2009.06.15
SelectKey in insert statement in mysql  (0) 2009.06.05
Posted by '김용환'
,