<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Debop on Medium]]></title>
        <description><![CDATA[Stories by Debop on Medium]]></description>
        <link>https://medium.com/@debop?source=rss-d32d715ab43a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VpJlgPuO_9kEevbfjW9QcQ@2x.jpeg</url>
            <title>Stories by Debop on Medium</title>
            <link>https://medium.com/@debop?source=rss-d32d715ab43a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 14:02:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@debop/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Alternatives To JPA: Part 1]]></title>
            <link>https://medium.com/@debop/alternatives-to-jpa-part-1-7b75a5245c41?source=rss-d32d715ab43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b75a5245c41</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[async]]></category>
            <category><![CDATA[jdbc]]></category>
            <category><![CDATA[non-blocking]]></category>
            <category><![CDATA[jpa]]></category>
            <dc:creator><![CDATA[Debop]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 05:55:42 GMT</pubDate>
            <atom:updated>2025-04-23T06:24:55.605Z</atom:updated>
            <content:encoded><![CDATA[<h3>Limitations of JDBC</h3><p>JDBC is inherently synchronous, which has become a bottleneck in handling large-scale data processing. Historically, there hasn’t been a clear solution to this issue.</p><p>In such environments, the following stopgap measures have been attempted:</p><ol><li>Transitioning to NoSQL (e.g., MongoDB, Cassandra, Elasticsearch)</li><li>Scaling up application servers</li></ol><p>The shift to NoSQL often involved significant trial and error. Many failures stemmed from adopting NoSQL without understanding its characteristics or from flawed designs that didn’t deliver expected performance. Even successful transitions faced challenges, such as operational inconveniences. While the rise of SaaS-based NoSQL solutions has alleviated some operational burdens, NoSQL still struggles with edge cases that weren’t anticipated during the design phase, making data modifications cumbersome.</p><p>Summarizing the challenges:</p><ol><li>Operational burdens like system scaling</li><li>Performance degradation due to designs not accommodating edge cases or evolving business logic</li><li>Underperformance in specific scenarios, often without clear solutions due to lack of expertise</li><li>In back-office domains, manual tasks often require new programs for each requirement</li><li>Management tasks concentrated among few due to a lack of experienced personnel in specific NoSQL technologies</li></ol><p>Initially, there was great anticipation for NoSQL adoption, but the low success rate made it challenging to advocate for. Post-development and during operations, the risks were significant, and many projects didn’t yield favorable results. Consequently, many developers and project managers have reverted to traditional databases.</p><p>Over the past decade, there’s been a trend to adopt NoSQL only in areas suited to its strengths, while relying on traditional databases for general data management and as the primary data store. Through numerous trials and errors, the roles of each solution have become more defined.</p><p>With databases chosen as the main data store, and their performance improving, coupled with the adoption of Microservices Architecture (MSA) allowing each application to have its own independent storage, natural scale-out has occurred in some cases.</p><p>However, many systems still rely on a single main data store, making application performance heavily dependent on database performance. In such cases, the only viable solution has been scaling up application servers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b75a5245c41" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Kotlin Exposed]]></title>
            <link>https://medium.com/@debop/introduction-to-kotlin-exposed-d69da3efab73?source=rss-d32d715ab43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d69da3efab73</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[non-blocking]]></category>
            <category><![CDATA[async]]></category>
            <category><![CDATA[exposed]]></category>
            <category><![CDATA[kotlin-exposed]]></category>
            <dc:creator><![CDATA[Debop]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 02:43:18 GMT</pubDate>
            <atom:updated>2025-04-23T02:43:18.921Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to Kotlin Exposed</h3><p>While working with Java’s JPA, I encountered challenges such as a steep learning curve and performance issues. This led me to explore alternatives like MyBatis, R2DBC, Vert.x SQL Client, and Kotlin Exposed.</p><p>After thorough evaluation, I found Exposed to be the most suitable solution for our production environment.</p><p>Kotlin Exposed is a lightweight SQL mapper and ORM that allows for easier and safer database interactions. It provides a type-safe DSL (Domain Specific Language) for SQL, ensuring compile-time checks and reducing runtime errors. While it doesn’t offer the extensive features of JPA, it covers commonly used ORM functionalities effectively.</p><h3>Key Features</h3><h3>Type-Safe DSL</h3><p>One major drawback of traditional SQL is the inability to catch syntax errors at compile time, as it’s interpreted at runtime. Tools like MyBatis or Spring’s SQL templates often lead to bugs due to typos or incorrect syntax. Personally, I prefer compile-time checks, which is why I favor Kotlin’s DSL approach.</p><p>For instance, the getMovieActorsCount function retrieves movie information along with the number of associated actors using Kotlin’s DSL:</p><pre>fun getMovieActorsCount(): List&lt;MovieActorCountDTO&gt; {<br>    log.debug { &quot;Get Movie actors count.&quot; }<br>    val join = MovieTable.innerJoin(ActorInMovieTable).innerJoin(ActorTable)<br>    return join<br>        .select(MovieTable.id, MovieTable.name, ActorTable.id.count())<br>        .groupBy(MovieTable.id)<br>        .map {<br>            MovieActorCountDTO(<br>                movieName = it[MovieTable.name],<br>                actorCount = it[ActorTable.id.count()].toInt()<br>            )<br>        }<br>}</pre><p>This approach allows for expressive and type-safe SQL queries.</p><h3>Lightweight DAO (Data Access Object)</h3><p>Exposed offers a lightweight ORM, eliminating the need for patterns like Repository or tools like EntityManager. Each entity’s companion object inherits from EntityClass, providing methods such as findById, new, all, find, and more.</p><p>For example, the ActorEntity class is defined as:</p><pre>class ActorEntity(id: EntityID&lt;Long&gt;) : LongEntity(id) {<br>    companion object : LongEntityClass&lt;ActorEntity&gt;(ActorTable)<br><br>    var firstName: String by ActorTable.firstName<br>    var lastName: String by ActorTable.lastName<br>    var birthday: LocalDate? by ActorTable.birthday<br>    val movies: SizedIterable&lt;MovieEntity&gt; by MovieEntity via ActorInMovieTable<br>}</pre><p>To fetch data, you can use either the DSL:</p><pre>ActorTable.selectAll()<br>    .where { ActorTable.id eq actorId }<br>    .firstOrNull()<br>    ?.toActorDTO()</pre><p>Or the DAO approach:</p><pre>ActorEntity.findById(actorId)?.toActorDTO()</pre><p>For simple entity operations, the DAO method is more straightforward.</p><h3>Support for Multiple Databases</h3><p>One advantage of ORMs is the ability to work across various database vendors. Exposed officially supports:</p><ul><li>H2</li><li>MariaDB</li><li>MySQL (v5 &amp; v8)</li><li>PostgreSQL</li><li>MS SQL Server</li><li>Oracle</li><li>SQLite</li></ul><p>I also tested CockroachDB, but encountered several conflicts, making it less viable at this time.</p><p>While companies often have predetermined databases, Exposed’s flexibility is beneficial when developing solutions or planning database migrations.</p><h3>Async/Non-Blocking Support (CPU-Bound, Coroutines)</h3><p>Traditional JPA operations are inherently synchronous due to JDBC’s nature. Although Exposed is also JDBC-based, it supports CPU-bound async/non-blocking operations using Kotlin Coroutines.</p><p>With Java 21’s Virtual Threads, JPA can achieve similar async behavior, but Exposed’s lightweight coroutine approach offers advantages in handling large-scale data processing.</p><p>For example, the getActorById function utilizes newSuspendedTransaction for coroutine-based DB operations:</p><pre>suspend fun getActorById(@PathVariable(&quot;id&quot;) actorId: Long): ActorDTO? {<br>    return newSuspendedTransaction(readOnly = true) {<br>        log.debug { &quot;current transaction=$this&quot; }<br>        actorRepository.findById(actorId)?.toActorDTO()<br>    }<br>}</pre><p>This enables seamless integration with frameworks like Spring WebFlux, enhancing responsiveness across services, including those using NoSQL databases.</p><h3>Conclusion</h3><p>My motivation to study and introduce Kotlin Exposed stems from the following:</p><ul><li>Databases are fundamental to services.</li><li>Database technologies have significantly improved (notably PostgreSQL and MySQL v8).</li><li>NoSQL is often limited to specific scenarios.</li></ul><p>While some services adopt NoSQL as their primary storage, many revert to traditional databases due to performance and operational advantages.</p><p>However, JPA’s limitations in flexibility, complex SQL support, and lack of async/non-blocking capabilities prompted the search for alternatives.</p><p>Kotlin Exposed (version 0.61.0) now supports most of these features, and future developments may include R2DBC support, further enhancing its capabilities.</p><p>For the full content, please refer to the original article in Korean: <a href="https://medium.com/@debop/kotlin-exposed-%EC%86%8C%EA%B0%9C-136f7ac0bf5d">Kotlin Exposed 소개</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d69da3efab73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin Exposed 소개]]></title>
            <link>https://medium.com/@debop/kotlin-exposed-%EC%86%8C%EA%B0%9C-136f7ac0bf5d?source=rss-d32d715ab43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/136f7ac0bf5d</guid>
            <category><![CDATA[exposed]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jdbc]]></category>
            <category><![CDATA[non-blocking]]></category>
            <dc:creator><![CDATA[Debop]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 02:34:11 GMT</pubDate>
            <atom:updated>2025-04-23T02:34:11.744Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>이 글은 <a href="https://debop.notion.site/Kotlin-Exposed-Book-1ad2744526b080428173e9c907abdae2">Kotlin Exposed Book</a> 의 첫번째 장의 글을 옮긴 것입니다. <br>전체 내용은 위의 사이트에서 보실 수 있습니다.</blockquote><h3>Kotlin Exposed 소개</h3><p>그동안 Java 진영의 JPA 를 사용하면서 겪었던 학습 상의 문제, 성능 불만족 등의 이유로 Mabatis, JPA/Hibernate 이외의 솔루션을 찾고 있었습니다.</p><p>R2DBC, Vertx SqlClient, Kotlin Exposed 등 다양한 라이브러리에 대해 검토한 결과, 현업에서 가장 적합한 솔루션이 Exposed 라고 판단했습니다.</p><p>Kotlin Exposed 는 Database 를 좀 더 쉽고, 안전하게 사용하기 위한 Lightweight SQL Mapper 이자 Lightweight ORM 입니다.</p><p>SQL 문법을 Kotlin DSL (Domain Specific Language) 로 표현하는 방법으로 타입 안정성을 보장해주고, JPA 처럼 아주 방대한 기능을 제공하지는 않지만, 자주 사용하는 기능에 대해서 ORM 방식을 제공합니다.</p><h3>주요 특징</h3><h3>Type Safe DSL</h3><p>Database의 SQL 문의 가장 큰 단점은 Script 언어와 같이 실행 시 인터프리터로 해석한 후에 실행되므로, 문법적 오류를 컴파일 시점에 알 수 없는 단점이 있습니다.</p><p>특히 MyBatis, Spring의 SQL Template 같은 경우 오탈자나 잘못된 SQL 문법 문제로 버그를 양산하는 경우도 많습니다. 개인적으로도 SQL 구문을 문자열로 사용하는 방식을 선호하지 않는 이유가 인터프리터 언어보다 컴파일 언어를 선호하는 것과 같은 맥락이라고 보시면 됩니다.</p><p>getMovieActorsCount 는 영화 정보와 출연자의 수를 조회하는 함수입니다. 여기서 보셨듯 Kotlin DSL 을 이용하여 join, group by 등 모든 SQL 문을 표현할 수 있습니다.</p><pre>fun getMovieActorsCount(): List&lt;MovieActorCountDTO&gt; {<br>    log.debug { &quot;Get Movie actors count.&quot; }<br>    val join = MovieTable.innerJoin(ActorInMovieTable).innerJoin(ActorTable)<br>    return join<br>        .select(MovieTable.id, MovieTable.name, ActorTable.id.count())<br>        .groupBy(MovieTable.id)<br>        .map {<br>            MovieActorCountDTO(<br>                movieName = it[MovieTable.name],<br>                actorCount = it[ActorTable.id.count()].toInt()<br>            )<br>        }<br>}</pre><h3>Lightweight DAO (Data Access Object)</h3><p>Lightweight ORM 이라고도 하는데, 따로 Repository 패턴을 거치지 않고, Entity Manager 같은 것은 없습니다만, 각 엔티티의 companion object 에서 상속받은 EntityClass 에서는 findById, findByIdAndUpdate, findSingleByAndUpdate, reload, forEntityIds, forIds, wrapRows, wrapRow, all, find, searchQuery, count new, wrap 등의 다양한 기능을 제공합니다.</p><p>ActorEntity 는 엔티티를 표현하는 속성값 외에 companion object: LongEntityClass&lt;ActorEntity&gt;(ActorTable) 을 구현했습니다. 이를 통해 ActorEntity 는 간단한 ORM 기능을 사용할 수 있습니다.</p><pre>class ActorEntity(id: EntityID&lt;Long&gt;): LongEntity(id) {<br>        **companion object: LongEntityClass&lt;ActorEntity&gt;(ActorTable)**</pre><pre>        var firstName: String by ActorTable.firstName<br>        var lastName: String by ActorTable.lastName<br>        var birthday: LocalDate? by ActorTable.birthday</pre><pre>        val movies: SizedIterable&lt;MovieEntity&gt; by MovieEntity via ActorInMovieTable<br>   }<br>}</pre><p>Exposed DSL 을 통해서 SQL 문을 실행하는 방법은 ActorTable 을 직접 이용하는 방법이 있습니다.</p><pre>ActorTable.selectAll()<br>    .where { ActorTable.id eq actorId }<br>    .firstOrNull()<br>    ?.toActorDTO()</pre><p>Exposed DAO 방식으로 SQL 문을 수행한다면 ActorEntity 를 직접 사용하면 됩니다.</p><pre>ActorEntity.findById(actorId)?.toActorDTO()</pre><p>간단한 엔티티 단위의 처리는 Exposed DAO 방식를 활용하는 편이 더 간단하고 쉽습니다.</p><h3>다양한 데이터베이스 지원</h3><p>ORM 장점 중에 하나가 다양한 데이터베이스를 벤더와 상관없이 사용할 수 있다는 점인데요, Exposed 도 다양한 데이터베이스를 지원합니다. 공식적으로 다음과 같은 DB를 지원합니다.</p><ul><li>H2</li><li>MariaDB</li><li>MySQL V5, V8</li><li>Postgres</li><li>MS SQL Server</li><li>Oracle</li><li>SQLite</li></ul><p>그 이외에 제가 테스트 해본 DB로는 Cockroach 도 있는데, 많은 기능이 충돌이 생겨서 아직 사용할 정도는 못됩니다.</p><p>보통 자체 시스템을 운영하는 회사의 경우에는 DB 가 이미 결정되어 있는 경우가 많기 때문에 크게 잇점이 없을 수 있습니다만, 솔루션을 만들거나 DB 전환을 계획한 경우에는 의미있을 수 있습니다.</p><h3>Async/Non-Blocking 지원 (CPU-Bounded, Coroutines)</h3><p>기존 JPA는 (모든 JDBC 기반) DB 작업이 태생적으로 동기 방식입니다. 트랜잭션 관리를 수행하기 위해서는 어쩔 수 없습니다.</p><p>Exposed 도 JDBC 기반이므로, 기본적으로는 동기 방식입니다만, Kotlin Coroutines 환경 하에서는 CPU-Bounded Async/Non-Blocking 을 지원할 수 있습니다.</p><p>최신 Java 21 의 Virtual Threads 를 사용한다면, JPA 도 CPU-Bounded Async/Non-Blocking 으로 작업할 수 있습니다만, Exposed 는 좀 더 경량화된 Coroutines 을 사용하므로서 대용량 처리에 좀 더 유리한 점이 있습니다.</p><p>getActorById 함수는 newSuspendedTransaction 함수를 이용하여 Coroutines 환경에서 Exposed DB 작업을 수행합니다.</p><pre>suspend fun getActorById(@PathVariable(&quot;id&quot;) actorId: Long): ActorDTO? {<br>    return newSuspendedTransaction(readOnly = true) {<br>        log.debug { &quot;current transaction=$this&quot; }<br>        actorRepository.findById(actorId)?.toActorDTO()<br>    }<br>}</pre><p>이렇게 되면, Spring Webflux 같은 Async/Non-Blocking 을 지원하는 프레임워크에서 DB 작업을 수행하기 위해서는 R2DBC, Vertx Sql Client 외에는 대안이 없었지만, Exposed 를 이용하면 쉽게 적용할 수 있게 되었습니다. 이는 서비스가 DB 뿐 아니라 다른 NoSQL 을 사용할 때 모두 Coroutines 방식으로 전환하여 응답성을 획기적으로 개선할 수 있는 방법이 될 수 있습니다.</p><h3>맺음말</h3><p>제가 Kotlin Exposed 를 공부하고, 소개하려고 마음 먹은 이유는 다음과 같습니다.</p><ul><li>Database 는 서비스의 기본적인 저장소이다</li><li>Database 기능 자체가 상당히 좋아졌다 (특히 Postgres, MySQL V8)</li><li>NoSQL 은 결국 특정 상황, 특정 기능에서만 사용된다</li></ul><p>서비스에서 메인 저장소를 NoSQL 로 하는 경우도 있지만, 다시 Database로 돌아오는 경우도 많아졌습니다. 그만큼 Database 성능이 좋아졌다는 반증이기도하고, 개발자가 운영 상의 잇점으로 Database 를 버릴 수 없는 점도 있다고 생각됩니다.</p><p>하지만 기존 JPA 만으로 만족하지 못했던 것은 좀 더 유연하고, 복잡한 SQL 문 작성 지원, Async/Non-Blocking 지원이 되는 솔루션을 원했기 때문입니다.</p><p>이제 Kotlin Exposed (version 0.61.0) 이 이런 대부분의 기능을 지원하고 있고, <strong><em>향후에는 R2DBC 방식도 지원할 계획</em></strong>이라, 기존 솔루션으로 성능, 운영상 애로점이 있는 개발자 분들은 한번 고려해 보시기를 추천합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=136f7ac0bf5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MongoDB 를 넘어 …]]></title>
            <link>https://medium.com/@debop/mongodb-%EB%A5%BC-%EB%84%98%EC%96%B4-d0ce56578962?source=rss-d32d715ab43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0ce56578962</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[rethinkdb]]></category>
            <category><![CDATA[arangodb]]></category>
            <dc:creator><![CDATA[Debop]]></dc:creator>
            <pubDate>Thu, 20 Jul 2017 14:56:34 GMT</pubDate>
            <atom:updated>2017-07-20T14:56:34.701Z</atom:updated>
            <content:encoded><![CDATA[<p>많은 NoSQL 을 사용해봤고, 운영도 했지만, 안정적으로 운영할 NoSQL을 새롭게 찾게 되는 것은 왜일까?</p><p>MongoDB 를 무의식적으로 사용하고 있는 나와 동료들에게서 MongoDB로 인한 운영 부담을 덜기 위해, 새로운 대안을 찾는 시기가 왔다.</p><p>MongoDB와 기능상에서는 유사하지만, 성능이 더 좋고, 운영 부담이 조금 덜한 Couchbase 부터 시작해서, RethinkDB, ArangoDB 등 많은 후보군을 두고 고민을 하고 있다.</p><p>내가 새로운 NoSQL 에 바라는 점은 다음과 같다.</p><blockquote>1. 운영이 쉬워야 한다. (Ops 전문가가 부족하기 때문)<br>2. Replication 과 Sharding 기능이 제공되어야 한다. <br>3.Write 성능이 MongoDB 이상이 되어야 한다.<br>4. 조회 시 Latency 뿐 아니라 시스템 부하도 적어야 한다.<br>5. Secondary Index 가 지원되어야 한다.<br>6. 기본적으로 Document based storage 가 지원되어야 한다.</blockquote><p>이런 점을 기반으로 몇 가지 NoSQL을 선정하고 기술 검토에 들어갔다.</p><h3><strong>1 RethinkDB (</strong><a href="https://www.rethinkdb.com/">https://www.rethinkdb.com/</a>)</h3><p>RethinkDB 는 Realtime DB라는 기치로 node 진영에서 인기가 있었던(?) DB이다. 예전부터 알고는 있었지만, Java 를 지원하지 않는 이유로 관심에서 멀어졌던 제품이다. 요즘 다시 찾아보니 많은 일들이 있었네요. 회사는 망하고, 제품은 오픈소스화 되어, Linux 재단에서 지원을 받고 있다고 하네요.</p><blockquote><a href="http://www.defmacro.org/2017/01/18/why-rethinkdb-failed.html">RethinkDB: why we failed</a></blockquote><p>위의 링크는 아마 RethinkDB 제작회사의 CEO가 회사를 접은 이후 쓴 RethinkDB가 왜 실패했는가를 분석한 글입니다.</p><p>제가 생각하기에도 초창기 node 진영에 어필은 했지만, 가장 시장이 큰 java 진영을 지원하지 않은 점이 가장 크고, realtime 이라는 기능을 너무 강조한 것이 패착이지 않나 싶습니다.</p><p>하지만, 현재 RethinkDB는 Linux 재단의 품으로 들어가 새롭게 제품 개발을 진행하고 있습니다.</p><blockquote><a href="https://www.rethinkdb.com/blog/2.3.6-release/">Annoucing RethinkDB 2.3.6</a></blockquote><p>2.x 부터는 Java 도 지원하고 (아직 Java 용 자료는 javascript 나 python에 비해 상대적으로 부족합니다만) 다시 활발히 개발이 진행되는 것 같아 급 관심이 갑니다.</p><p>RethinkDB 기존 버전은 MongoDB에 비해 성능이 느린 점도 문제점으로 지목되었는데, RethinkDB 2.x 부터는 상당한 개선을 이루어 현재는 성능면에서 MongoDB에 뒤지지 않습니다.</p><p>거기다가 다양한 JOIN 지원, Realtime 지원, Cluster 지원 등 MongoDB가 지원하지 않는 기능 및 강력한 질의어 API (<a href="https://www.rethinkdb.com/docs/introduction-to-reql/">ReQL</a>) 을 지원하여, 상당히 강력하고 성능 좋은 조회 기능까지 제공됩니다.</p><p>제가 검토하는 현재로서는 RethinkDB 개발진이 더 보강되어, 더 많은 기능이 속도감있게 지원 되었으면 합니다. 오픈소스 중 자금지원을 못 받는 프로젝트의 경우 중간에 중단될 수 있는 위험이 있으니 섣불리 선택할 수 없는 상황이라 무척 아쉽다는 생각이 듭니다.</p><h3><strong>2. ArangoDB ( </strong><a href="https://www.arangodb.com/">https://www.arangodb.com/</a>)</h3><p>ArangoDB 는 Graph DB를 찾다가 Neo4j, OrientDB 이후에 발견한 제품입니다. 특이하게 Graph DB, Document DB, Key-Value 모두 지원하면서도, 성능면에서도 MongoDB를 뛰어넘는 DB라 소개하고 있습니다.</p><blockquote><a href="https://www.arangodb.com/2015/10/benchmark-postgresql-mongodb-arangodb/">Benchmark: PostgreSQL, MongoDB, Neo4j, OrientDB, ArangoDB (2015)</a></blockquote><p>2015년 10월에 쓴 글이므로, 현재와는 많이 차이가 있고, ArangoDB에서 자체 수행한 것이라 감안하고 보더라도 ArangoDB의 강점이 분명 있다고 봐집니다.</p><p>ArangoDB 또한 Zero Configuration 으로 Cluster를 구성할 수 있고, Cluster의 성능이 다음과 같이 Linear 하다는 게 큰 장점 중에 하나라 봐집니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*gMQ9-fzbVXpMDziwkADrOg.jpeg" /><figcaption><a href="https://mesosphere.com/blog/2015/11/30/arangodb-benchmark-dcos/">https://mesosphere.com/blog/2015/11/30/arangodb-benchmark-dcos/</a></figcaption></figure><p>ArangoDB 도 RethinkDB와 유사하게 <a href="https://mesosphere.com/blog/2015/11/30/arangodb-benchmark-dcos/"><strong>AQL</strong></a> 이라는 Query Language 를 지원합니다. RethinkDB 는 Java API 라면, AQL 은 SQL의 변종이라 보시면 되겠네요.</p><p>최근 출시한 3.2 에서는 Facebook RocksDB 를 저장소로 할 수 있도록 하여, 더욱 성능이 개선되었다고 합니다. 안정된 회사에서 Comercial, Community 버전 모두 지속적으로 지원하여 안정적이라는 점이 잇점을 더합니다.</p><h3><strong>맺는말</strong></h3><p>앞으로도 더 많은 제품을 검토할 예정이지만, 조만간 위 두 가지 제품중에 하나를 선택해서 프로젝트를 진행할 생각입니다.</p><p>RethinkDB의 불안한 미래 vs 오버스러운 기능의 ArangoDB 중에 선택을 해야겠지요^^</p><p>이제 MongoDB 운영 부담을 벗어던지고, 좀 더 강력하고 쾌적한 환경에서 개발할 수 있으면 좋겠습니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0ce56578962" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Netty, RxJava, Reactor-IO]]></title>
            <link>https://medium.com/@debop/netty-rxjava-reactor-io-2732185d5fd1?source=rss-d32d715ab43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2732185d5fd1</guid>
            <category><![CDATA[netty]]></category>
            <category><![CDATA[rxjava]]></category>
            <category><![CDATA[reactor]]></category>
            <dc:creator><![CDATA[Debop]]></dc:creator>
            <pubDate>Tue, 03 May 2016 05:50:31 GMT</pubDate>
            <atom:updated>2016-05-03T05:50:31.824Z</atom:updated>
            <content:encoded><![CDATA[<p>요즘 서버 통신 관련 프로그래밍을 해야 해서, 결국 Netty 를 공부하고 있음 …</p><p>Netty 를 보다보니 서버쪽도 쉽게 개발할 수 있지만, 클라이언트쪽도 쉽게 개발 할 수 있다는 걸 알 수 있었음 …</p><p>거기다가 Reactive Streams 을 구현한 RxJava 와 Reactor 에 Netty 관련 확장 모듈이 있음을 알게되었고, 이제 둘 중 하나를 채택해야 할 시점임 …</p><p>고민되네….</p><p><a href="https://github.com/ReactiveX/RxNetty">RxNetty</a> 냐 <a href="https://github.com/reactor/reactor-io">reactor-io</a> 냐 …</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2732185d5fd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Redis Client Benchmark]]></title>
            <link>https://medium.com/@debop/redis-client-benchmark-898aa1c1c5d7?source=rss-d32d715ab43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/898aa1c1c5d7</guid>
            <dc:creator><![CDATA[Debop]]></dc:creator>
            <pubDate>Sat, 02 May 2015 04:08:12 GMT</pubDate>
            <atom:updated>2015-05-02T04:08:12.642Z</atom:updated>
            <content:encoded><![CDATA[<p>보통 특정 서버를 사용하면, 공식 Client Library 가 있는 경우는 드믈고, 대부분 open source 로 많이 제공되고 있지요. Redis 가 워나 인기가 높아 아주 많은 언어로 client library를 제공하고 있습니다.</p><p>제가 java로 개발할 때는 너무도 유명한 <a href="https://github.com/xetorthio/jedis">jedis</a> 를 사용했습니다. jedis 의 장점은 안정적이면서, 활발한 활동으로 redis-server가 버전이 올라가면서 추가된 기능을 상당히 빨리 제공한다는 점입니다.</p><p>그러다가 scala 언어를 주로 쓰게 되고, <a href="http://akka.io/">akka</a> 라는 비동기, Non-Blocking 을 기본으로 사용하는 시스템을 알게 되고, 엄청난 성능을 자랑한다는 걸 알고 이거 좋겠다 싶었는데, scala 언어로 만든 redis-client 중에 <a href="https://github.com/etaty/rediscala">rediscala</a> 라는 놈이 akka를 이용해 통신을 한다고 해서 공부 해봤습니다.</p><p>처음 rediscala 를 배울 때, 미리 jedis 와 rediscala 의 속도 비교를 해 봐야겠다고는 생각했지만, 워낙 Akka의 명성이 자자해서, 심정적으로 당근 빠르겠지 하고 지나갔습니다.</p><p>근데 문제가 터졌습니다. rediscala 로 모두 전환한 후, 실제 운영하는 서비스에 올렸는데, CPU 폭주 .. 성능 저하 등등… 도저히 쓰지 못할 지경이였습니다. 이것 때문에 부랴부랴 다시 jedis로 되돌리고, 뭐가 잘못되었는지 파악하기 위해, 여러가지 테스트를 수행해 봤습니다.</p><p>결론부터 말하면, rediscala 는 엄청 좋은 성능을 내는 것이 맞고, 문제가 된 것은 제가 잘못 사용했기 때문이었습니다. rediscala 가 비동기 통신이고, scala <a href="http://docs.scala-lang.org/overviews/core/futures.html">Future</a> 를 사용하는데, scala에 익숙하지 않은 동료들을 위해 synchronous 하게 사용할 수 있도록 wrapping 한 클래스를 사용한 것이 문제를 일으킨 것이었습니다.</p><p>결국 모든 redis 호출 부분을 비동기로 처리하도록 변경하고, 테스트한 결과 감으로만 빠르겠지 했던 것이 생각보다 더 크더군요.</p><h4>Benchmark</h4><p>아래 성능 측정 표는 get/set, lpush/rpop/lrange, zadd/zscore 등 제가 자주 사용하는 명령어에 대한 성능 측정한 결과입니다. 성능측정에 사용한 컴퓨터는 MacBook Pro i7, Memory: 16GB, SSD:500G 이고, <a href="http://scalameter.github.io/">ScalaMeter</a> 라는 라이브러리를 이용했습니다.</p><p>측정한 코드는 <a href="https://github.com/debop/redis-client-benchmark">Redis Client Benchmark 소스</a> 를 참고하시면 됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*4gHZzgmAEC3K1fSu.png" /></figure><h4>측정 결과를 분석</h4><ol><li>Jedis 는 동기 방식이라 client 하나만 사용하면 느리다.</li><li>꼭 JedisPool 을 이용하여 적절한 설정을 통해 복수의 client 를 이용하게 해야 한다.</li><li>JedisPool로 측정 시, CPU와 같은 갯수인 8개로 설정했는데, 숫자를 늘려 측정하면 더 좋은 성능을 기대할 수 있을 것이다.</li><li>rediscala 가 모든 면에서 압도적인 성능을 발휘하는 것은 akka 시스템의 messaging 전달 방식에 기인한다고 볼 수 있다.</li><li>특이하게 lrange 같이 많은 데이터 양을 받아오는 것에 대해서 rediscala 가 상당히 느린데, 이유를 모르겠다. 추측한다면 rediscala 는 데이터를 ByteString으로 변환하여 redis-server와 통신하는데, 데이터 양이 커지면 성능이 느려지는 것이 아닌가 추측할 뿐이다.</li><li>rediscala의 data 처리 시, 압축이나 속도가 빠른 serializer 를 이용한다면 더 좋은 성능을 낼 것이라 생각된다. 참고로 <a href="https://github.com/debop/hibernate-rediscala">hibernate-rediscala</a> 라는 hibernate 2nd cache provider 는 캐시 정보를 snappy 와 fst 를 이용하여 기본 serializer보다 훨씬 좋은 성능을 낼 수 있음을 확인했다.</li></ol><h4>결론</h4><p>우선 어떤 라이브러리를 새로 도입하게 된다면, 장점과 단점을 파악하고, 장점을 최대한 발휘할 수 있는 방법과 단점을 최소화할 방법을 생각한 후, 기존 방식과의 객관적인 비교를 꼭 수행해야 한다는 점이다. 이게 한번에 끝나는게 아니라, 또 다른 새로운 것을 도입한다고 하더라도, 기존 테스트 결과로 비교할 수도 있고, 코드가 남아있다면 같은 환경에서 벤치마킹을 수행할 있으니 지속적인 개선을 수행할 수 있을 것이다.</p><ol><li>Akka 가 대단하다. 향후 시스템의 기본 통신은 Akka 를 기반으로 해야겠다.</li><li>비동기 프로그래밍에 대해 개발자에게 교육시키는 것이, 편하게 사용하도록 Wrapping class를 제공하는 것보다 장기적으로 도움도 되고, 서버 성능도 보장해준다.</li><li>라이브러리 변경 시에는 특히 성능문제라면 성능 측정은 기본이다^^</li><li>scala 언어 자체는 java 보다 느리다. (immutable 을 기본으로 사용하라는 지침때문에) 이런 것을 극복할 수 있는 것은 사실상 엄청 느린 네트웍, IO bound 에서 속도를 높혀주는 것으로 상쇄하고도 남는다.</li></ol><p>반응 2개</p><p><em>Originally published at </em><a href="http://debop.tumblr.com/post/98555122056/redis-client-benchmark"><em>debop.tumblr.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=898aa1c1c5d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ConnectionPool 성능 측정 (Updated)]]></title>
            <link>https://medium.com/@debop/connectionpool-%EC%84%B1%EB%8A%A5-%EC%B8%A1%EC%A0%95-updated-b446a448a830?source=rss-d32d715ab43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b446a448a830</guid>
            <dc:creator><![CDATA[Debop]]></dc:creator>
            <pubDate>Sat, 25 Oct 2014 08:44:48 GMT</pubDate>
            <atom:updated>2014-10-25T08:44:48.918Z</atom:updated>
            <content:encoded><![CDATA[<p>그동안 미뤄왔던 Database Connection Pool 성능 측정을 수행해 봤습니다. 저는 그동안 <a href="http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html">Tomcat CP</a>, <a href="https://github.com/wwadge/bonecp">BoneCP</a> 를 주로 써 왔는데, 올 초에 <a href="https://github.com/brettwooldridge/HikariCP">HikariCP</a> 를 알게되어 사용하게 되었습니다.</p><p>그동안 BoneCP의 benchmark 결과를 보고, 상당히 빠르구나… 했는데, HikariCP 에서 제공하는 Benchmark 결과를 보고, 이건 뭐야? 이렇게 빨라? 믿기지 않을 정도였지요…</p><p>하지만, 공식사이트의 사용법 중 maximumPoolSize 를 10 으로 놓고 작업해야 한다는 것과 minimumIdle 크기를 지정하지 않아도 된다는 것을 충실히 따라서 테스트 해보니, 실제 환경에서는 쓸 수 없을 정도로 Connection Pool timeout 이 생겨, 결국 테스용으로 전락했습니다.</p><p>HikariCP가 너무 빨라 pool size 가 10이라도 충분하다는 말이었는데, 실제 테스트 해보니 부족하여 32, 64 등으로 증가시켜 봤습니다만, 쓸데 없이 많이 만드는 것 아닌가 싶기도 하고, 결국 minimumIdle 의 크기 2~4 로 지정하고 테스트 하니 제대로 원하는 결과를 얻었습니다.</p><p>이에 고무되어, 내 나름대로 설정한 값들로 성능 측정을 해보자! 라는 생각이 들어, 부랴부랴 제작해 봤습니다.</p><p><strong><em>소스 : </em></strong><a href="https://github.com/debop/connectionpool-benchmark"><strong><em>conectionpool-benchmark</em></strong></a></p><p>제작은 <a href="http://www.scala-lang.org/">scala</a> 2.11 을 사용했고, benchmark 는 <a href="http://scalameter.github.io/">scalameter</a> 를 이용했습니다.</p><p>측정 방법</p><ol><li>cycle connection : 단순히 connection 을 얻고, 즉시 닫기</li><li>cycle statememt : connection 얻기, statement 실행, statement 닫기, connection 닫기</li></ol><p>두 가지를 수행했습니다. 다른 benchmark 랑 다른 점은 단순 loop 로 반복테스트를 한 것이 아니라, scala 의 병렬 프로그래밍 기능을 이용하여 multi-thread 환경에서 동시에 작업을 수행할 수 있도록 했습니다. 이 방식이 실제 application에서 동작하는 방식과 가장 유사할 듯 합니다.</p><p>결과는 상상 이상입니다.</p><p>cycle connection</p><p>벤치마크 테스트 시 scalameter 의 간이 테스트로 했을 경우, 제대로 측정이 안되고, 코드가 무시되어 잘못된 결과가 나와서 microbenchmark 로 변경하여 재측정을 했습니다.</p><p>측정 결과 HikariCP가 3배에서 7배 정도 빠르네요. BoneCP가 Tomcat 보다 빠를 줄 알았는데 아니네요… ㅠ.ㅠ</p><p>cycle statement :</p><p>실제 운영환경과 가장 유사한 테스트라고 생각되는데, HikariCP가 2배 정도 빠르네요. 생각보다 BoneCP가 TomcatCP보다도 느리네요.</p><p>ConnectionPool 성능의 영향이 미미할 수도 있지만, 아주 많은 Tx를 발생시키는 환경에서는 중요성이 커지기 마련입니다. 앞으로는 HikariCP만을 사용할 것 같네요^^</p><p>아래 Chart 는 성능 측정한 결과를 chart 로 표시한 것인데, x 축은 실행횟수, y 축은 실행 시간입니다. y 값이 낮을 수록 성능이 좋은 것입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*PF_ePVBJbLeAiRVQ.png" /></figure><p>반응 2개</p><p><em>Originally published at </em><a href="http://debop.tumblr.com/post/99653590666/connectionpool-updated"><em>debop.tumblr.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b446a448a830" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>