'2021/08'에 해당되는 글 10건

  1. 2021.08.30 [NLP] 자연어 처리 문서 링크
  2. 2021.08.19 [Architecture] Microservices Pattern.
  3. 2021.08.18 [DBMS] QueryPie
  4. 2021.08.18 [Java] html strip + multi whitespace strip
  5. 2021.08.12 [Elasticsearch] _routing 활용에 따른 특정 shard 만 _forcemerge 하고 싶을 경우.
  6. 2021.08.12 [Elasticsearch] RESTful API + ID:PASSWORD 요청.
  7. 2021.08.11 [Elasticsearch] Contribute 하고 싶으세요.
  8. 2021.08.09 [MySQL] HikariCP Connection Pool 관리 예.
  9. 2021.08.04 [Elasticsearch] force merge 에 대한 정리
  10. 2021.08.02 [Log4J2] Executable Jar + Springboot framework 사용 예.

[NLP] 자연어 처리 문서 링크

ITWeb/스크랩 2021. 8. 30. 11:59

책을 출간 하기 위해 작성 하고 계시는 것 같습니다.

그래서 링크만 걸어 봅니다. ^^

 

딥 러닝을 이용한 자연어 처리 입문 : https://wikidocs.net/book/2155
동일 저자가 만든 PyTorch 학습 자료 : https://wikidocs.net/book/2788
이 책을 위해 제작한 이미지 자료 공유 (영리적 목적 제외 자유롭게 사용) : https://www.slideshare.net/wonjoonyoo/ss-188835227
딥 러닝 추천 자료 : https://www.d2l.ai/index.html
NLP 참고 자료 : http://www.phontron.com/class/nn4nlp2019/schedule.html, https://github.com/makcedward/nlp
한국어 NLP 논문 모음 : https://github.com/papower1/Awesome-Korean-NLP-Papers

:

[Architecture] Microservices Pattern.

ITWeb/스크랩 2021. 8. 19. 10:35

https://microservices.io/patterns/index.html

 

Microservices Pattern: A pattern language for microservices

Microservices.io is brought to you by Chris Richardson. Experienced software architect, author of POJOs in Action, the creator of the original CloudFoundry.com, and the author of Microservices patterns. Chris helps clients around the world adopt the micros

microservices.io

 

:

[DBMS] QueryPie

ITWeb/스크랩 2021. 8. 18. 13:27

https://www.querypie.com/ko

 

QueryPie | Centralized Data Access and Privacy Control across the Cloud

QueryPie improves data governance within your organization by centralizing data access policies.

www.querypie.com

 

:

[Java] html strip + multi whitespace strip

ITWeb/개발일반 2021. 8. 18. 11:30
content = content.replaceAll("<[^>]*>", "");  // html strip
content = content.replaceAll("( )+", " " );   // multi whitespace to single whitespace

사용할 일이 있는데 기억력이 떨어져서 기록 해 봅니다.

:

[Elasticsearch] _routing 활용에 따른 특정 shard 만 _forcemerge 하고 싶을 경우.

Elastic/Elasticsearch 2021. 8. 12. 14:07

그냥 pull request 날렸습니다.

https://github.com/elastic/elasticsearch/pull/76400


그러나 Contributor Agreement 를 안했다고 하는데 이것 참.. 
했는데 왜 저게 나오는지 도대체 Docu Sign 을 몇 번을 했는지 모르겠네요 ㅡ.ㅡ;


코드를 확인해 보니 _forcemerge API 에는 특정 shard 만 지정 하는 기능은 없었습니다.

뭐 어떻게 보면 당연한 이야기지만, 그래도 _routing 을 사용 하면서 특정 shard 로 operation 이 집중되게 되면 해당 shard 의  segments 파일이 많이 생성 될 수도 있습니다.

 

그래서 코드를 좀 고쳤습니다.

contribute 을 위해 pull request 를 올려야 하는데 이 귀차니즘을 어찌 하죠.

암튼 별건 아니라서 일단 코드 부터 올려 놓습니다. 

 

 

:

[Elasticsearch] RESTful API + ID:PASSWORD 요청.

Elastic/Elasticsearch 2021. 8. 12. 13:18

분명 어딘가에 기록해 두었는데 이걸 왜 못찾고 있는 거지..ㅡ.ㅡ;

 

http://elastic:password@localhost:9200/test-index

 

elasticsearch 에서 기본 인증을 사용 할 경우 API token 사용 이런게 아니라면 단순하게는 저렇게 보낼 수 있습니다.

 

https://www.ietf.org/rfc/rfc2617.txt

공식 스펙은 위 문서 참고 하시면 됩니다. (Basic Authentication)

 

URL 로 보내기 싫으시면 header 로 보내시면 됩니다.

 

elastic:password 를 base64 인코딩 하시고 "Authorization" 헤더로 값을 보내시면 되겠습니다.

 

KEY : Authorization

VALUE : Basic ZWxhc3RpYzpwYXNzd29yZA==

 

:

[Elasticsearch] Contribute 하고 싶으세요.

Elastic/Elasticsearch 2021. 8. 11. 14:00

Quick 하게 아래 처럼 일단 시작 부터 해봅시다.

 

[Elasticsearch Contribute]
https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md

소스코드 내려 받고 elasticsearch 7.14.0 빌드 및 실행
운영 환경에서 실행 시 jdk 11 로 가능 하지만 빌드 시는 jdk 16 을 요구 합니다.

% jenv local 16
% ./gradlew :run

 

:

[MySQL] HikariCP Connection Pool 관리 예.

ITWeb/개발일반 2021. 8. 9. 08:12

 

HikariCP 를 사용하고 있는데 Connection Pool 에 대한 반납과 재사용이 원활 하지 않을 때가 있습니다.

Application 내부에서 사용과 반납을 너무 빈번하게 하고 있을 경우 이런 문제가 발생 하는 것 같습니다.

보통은 별 문제 없이 사용을 했으나 이런 문제가 발생 한다면 명시적으로 Close 를 해주고 다시 Connection 을 생성해 주면 문제를 해소 할 수 있습니다.

 

기억하기 위해 기록 합니다.

 

    config.setDriverClassName("com.mysql.cj.jdbc.Driver");
    config.setJdbcUrl("jdbc:mysql://....");
    config.setUsername(user);
    config.setPassword(pwd);
    config.setMaximumPoolSize(maxPoolSize);
    config.setMinimumIdle(minimumIdle);
    config.setConnectionTimeout(30000);
    config.setValidationTimeout(10000);
    config.setConnectionTestQuery("SELECT 1");
    config.addDataSourceProperty("autoReconnect", "true");
    config.addDataSourceProperty("serverTimezone", "Asia/Seoul");
    config.addDataSourceProperty("cachePrepStmts", "true");
    config.addDataSourceProperty("prepStmtCacheSize", "250");
    config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
    config.addDataSourceProperty("dataSource.useServerPrepStmts", "true");
    config.addDataSourceProperty("characterEncoding","utf8");
    config.addDataSourceProperty("useUnicode","true");
    
    this.ds = new HikariDataSource(config);

 

getConnection() 은 pool 에서 얻어 옵니다.

getConnection().close() 하면 pool 을 반납 하게 됩니다. 

 

근데 이게 반납과 재사용이 잘 안된다. 그러면 ds.close() 하고 다시 connection 을 생성 합니다. (HikariDataSource ds)

 

:

[Elasticsearch] force merge 에 대한 정리

Elastic/Elasticsearch 2021. 8. 4. 08:12

공식 문서 참고)

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html

 

API)

POST /my-index-000001/_forcemerge

 

force merge 는 너무 많이 생성된 Segments 파일을 병합 하거나 삭제 된 문서를 물리적으로 병합 하면서 제거 하거나 하는 작업을 수행 하게 됩니다.

 

보통은 merge policy 에 의해서 자동으로 수행이 되긴 하지만 간혹 수동으로 실행을 해야 할 때도 발생을 합니다.

그럼 Segments 파일을 어느 정도 수준으로 유지 하는게 좋을까요?

 

그 전에 확인할 사항이 있습니다.

 

1. Segment 파일에 문서 수가 많나요?

2. Segment 파일에 문서의 크기가 큰 것일까요?

 

결국 이 Segments 파일은 IndexWriter 즉, 색인 보다는 검색에 영향을 많이 주는 요소라고 보면 됩니다.

 

짧은 용량의 Segments 파일이 많이 있다고 가정 하면 파일 수 만큼의 IndexeReader 가 준비 되어야 하고 그에 맞는 thread 가 일을 해야 하기 때문에 다소 성능이 떨어 질 수도 있습니다.

반대로, 용량이 큰 Segments 파일이 있다고 하면 Single thread 로 동작 하기 때문에 역시 성능이 떨어 질 수 있기도 합니다.

 

그래서 가장 최적의 Segment file 의 크기와 수를 구해야 검색 성능을 확보 할 수 있습니다.

보통은 Primary shard 와 Replica shard 를 가지고 접근을 하게 됩니다. 그러다 Node 수준까지 접근 하게 되고 더 나아가 Application 수준까지 ...

 

Segment 파일이 가질 수 있는

- 최대 문서의 수는 Integer.MAX_VALUE (2,147,483,519) 만큼 가질 수 있습니다.

- 문서 하나의 최대 크기는 2GB 입니다.

 

제가 제안 하는 범용적인 Segment 파일은

- 최대 문서 수는 1천만 ~ 5천만

- Segment file 크기는 2GB ~ 5GB

- Segment file 수는 Core 크기와 같거나 1/2 만큼

정도 인것 같습니다.

 

Segment 는 Lucene 기준으로 검토를 하셔야 하고 Elasticsearch 기준으로 확장 한다고 하면 Shard 까지 검토를 하셔야 합니다.

 

제가 제안한 정보를 기준으로 단순 예를 들어 보면)

- 코어가 10개 라고 하고

- 1/2 만큼의 Segments file : 5개

- Shard 1개의 크기는 5 개 Segments file x 2GB : 10GB

 

대략 Node와 Shard size estimation 하는 방법에서 제시 한 것과 어느 정도 부합 한다는 것을 볼 수 있습니다.

 

:

[Log4J2] Executable Jar + Springboot framework 사용 예.

ITWeb/개발일반 2021. 8. 2. 20:45

 

springboot framework 을 이용해서 executable jar 구현 시 log4j2 사용 예)
- @Slf4j 사용
- logback.xml 사용
- -Dlogback.configurationFile=$DIR_HOME/logback.xml

로그가 중복으로 남을 경우)
https://logging.apache.org/log4j/2.x/manual/configuration.html#Additivity
- <logger name="..." ... additivity="false" />
- 단순하게 보면, Logger 에 선언 된 appender 로 한번 기록하고 root logger 에 의해서 한번 기록 하게 되는 구조 입니다.

build.gradle 예)
configurations.all {
  exclude module: 'spring-boot-starter-logging'
}
...중략...
dependencies {
...중략...
  compile group: 'org.slf4j', name: 'slf4j-api', version: "${props.getProperty('slf4j')}"
  compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: "${props.getProperty('log4j')}"
  compile group: 'ch.qos.logback', name: 'logback-classic', version: "${props.getProperty('logback')}"
  compile group: 'ch.qos.logback', name: 'logback-core', version: "${props.getProperty('logback')}"
...중략...
}

 

: