jvm의 gc 로그를 사용할 때 아래와 같이 사용하는 것이 좋다. 디스크 용량을 넘어서지 않도록 용량/크기를 제어해야 한다.


gc 로그 파일을 작은 크기로, 여러 개로 나누거나


JVM_FLAGS="-verbosegc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:GCLogFileSize=1m -XX:NumberOfGCLogFiles=100 "



gc 로그파일을 크고 작은 크기로 나눠도 좋을 것 같다.



JVM_FLAGS="-verbosegc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:GCLogFileSize=100m -XX:NumberOfGCLogFiles=5"

Posted by '김용환'
,

스칼라 빈 값 정의

scala 2018. 1. 11. 19:22



전역 변수는 아래와 같이 _를 사용해서 정의할 수 있다.

var i: Int = _

var s: String = _



로컬 변수는 아래와 같이 

var response: LogResponse = _



Posted by '김용환'
,


string(object) 타입을 Boolean 값으로 변환하고 싶을 때. 다음과 같이 사용한다.


var a = Boolean(aaaa);








Posted by '김용환'
,



카프카 서버 성능에 크게 영향을 미치는 요인이 acks, retries, batch.size 이다..





https://www.slideshare.net/JiangjieQin/producer-performance-tuning-for-apache-kafka-63147600


https://www.youtube.com/watch?v=oQe7PpDDdzA


https://ko.hortonworks.com/blog/microbenchmarking-storm-1-0-performance/







Posted by '김용환'
,


self time - 메소드에서 소요된 전체 시간(락/블러킹 포함)


self time(cpu) - 메소드에서 소요된 전체 시간(락/블러킹 제외) 


두 값을 비교하면 멀티 쓰레드 환경 관점으로 특별히 비교할 수 있다.

Posted by '김용환'
,



Play2-React를 개발하던 중에 아래와 같은 에러가 크롬에서 발생했다. 


Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 404.




https://www.playframework.com/documentation/2.6.x/CorsFilter를 참고로 설정을 수정했다.


play.filters.enabled += "play.filters.cors.CORSFilter"


play.filters.cors {

  pathPrefixes = ["/", ...]

  allowedOrigins = ["http://localhost", ...]

  allowedHttpMethods = ["GET", "POST"]

  allowedHttpHeaders = ["Accept"]

  preflightMaxAge = 3 days

}




처음에는 404, 정책을 잘 지정하지 못하면 403이 나타난다.


allowedOrigins = ["http://localhost:9000", ...]



다음과 같이 모두 개방하면 테스트는 편해진다. 상용에서는 보안을 위해서 잘 수정하는 것이 좋다. 


(테스트용)

play.filters.hosts {

  allowed = ["."]

}


(상용)

play.filters.hosts {

    allowed = ["localhost", ".kakao.com", "localhost:9000", "local.google.com:9000", "local.google.com:4200"]

}




클라이언트(js)에서도 다음과 같이 수정한다. 



superagent

                .get('http://localhost:9000/log')

                .set('http.cors.enabled', true)

                .set('http.cors.allow-origin', "\"*\"")

                .query({...})

                .retry(2)

                .end((err, res) => {

                 }



이제 요청하면 정상적으로 동작하는 지 확인할 수 있다. 

Posted by '김용환'
,


회사에서 발생했던 mysql driver 의 크리티컬 이슈 


5.1.45 이상 버전으로 업그레이드가 피요하다.


https://bugs.mysql.com/bug.php?id=88242




Added the following entry to the Connector/J 5.1.45 changelog: "Normally, when the socketTimeout option has been set and a socket timeout occurs on the client side, the server may continue working and returning query results. At the next query executed after the timeout, Connector/J first clears the socket input stream and then sends a ping request to the server. However, an error occurred if the autoReconnect option was set to true and, after reconnection, a new query was executed by Connector/J, and the results from the previous queries arrived before Connector/J sent its ping request to the server, in which case the old packages might be mistaken as results for the new query. This fix corrects the issue by forcibly closing the network resources after a communication or IO exception. The next statement execution recreates the IO stream if autoReconnect=true; otherwise, the connection stays closed."


Posted by '김용환'
,

css의 id와 class의 차이

web 2018. 1. 8. 14:29



* ID's are unique

Each element can have only one ID

Each page can have only one element with that ID


* Classes are NOT unique

You can use the same class on multiple elements.

You can use multiple classes on the same element.


The “id=something” can be used to style one HTML element, whereas the “class=something” could be used to style multiple elements.


https://css-tricks.com/the-difference-between-id-and-class/


Posted by '김용환'
,



ubuntu에서 apt-get update가 행이 걸린다면 다음 로그를 보거나 strace로 확인한다. 


$ sudo vi /var/log/apt/term.log

$ sudo vi /var/log/dpkg.log

$ sudo vi /var/log/apt/history.log

$ strace apt-get update


잘못된 주소의 파일이 있거나, mirroring에 실패한 경우가 있을 수 있다. 



Posted by '김용환'
,



ES5에서는 require, ES6에서는 import를 사용한다.


import PropTypes from 'prop-types'; // ES6

var PropTypes = require('prop-types'); // ES5 with npm

Posted by '김용환'
,