未加星标

MariaDB Java Connector Driver Performance

字体大小 | |
[数据库(mysql) 所属分类 数据库(mysql) | 发布者 店小二05 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏
MariaDB java connector performance

We always talk about performance. But the thing is always "Measure, don't guess!".

A lot of performance improvement has been done lately on the MariaDB Java Connector. So, what the current driver performance?

Let me share a benchmark result of 3 jdbc drivers permitting access to a mysql/MariaDB database: DrizzleJDBC , MySQL Connector/J and MariaDB java connector .

Driver's versions are the latest GA available version at the time of writing this blog:

MariaDB 1.5.3 MySQL 5.1.39 Drizzle 1.4 The benchmark

JMH is an Oracle micro-benchmarking framework tool developed by Oracle, delivered as openJDK tools, that will be the official java 9 microbenchmark suite. Its distinctive advantage over other frameworks is that it is developed by the same guys in Oracle who implement JIT (Just In Time compilation) and permit to avoid most of micro-benchmark pitfalls.

Benchmark source: https://github.com/rusher/mariadb-java-driver-benchmark .

Tests are pretty straightforward if you are familiar with java.

Example:

public class BenchmarkSelect1RowPrepareText extends BenchmarkSelect1RowPrepareAbstract { @Benchmark public String mysql(MyState state) throws Throwable { return select1RowPrepare(state.mysqlConnectionText, state); } @Benchmark public String mariadb(MyState state) throws Throwable { return select1RowPrepare(state.mariadbConnectionText, state); } @Benchmark public String drizzle(MyState state) throws Throwable { return select1RowPrepare(state.drizzleConnectionText, state); } } public abstract class BenchmarkSelect1RowPrepareAbstract extends BenchmarkInit { private String request = "SELECT CAST(? as char character set utf8)"; public String select1RowPrepare(Connection connection, MyState state) throws SQLException { try (PreparedStatement preparedStatement = connection.prepareStatement(request)) { preparedStatement.setString(1, state.insertData[state.counter++]); try (ResultSet rs = preparedStatement.executeQuery()) { rs.next(); return rs.getString(1); } } } }

Tests using INSERT's queries are sent to aBLACKHOLE engine with the binary log disabled, to avoid IO and dependency on the storage performance. This permit to have more stable results.

(Without using the blackhole engine and disabling binary log, execution times would vary up to 10%).

Benchmark have been executed on MariaDB Server 10.1.17 and MySQL Community Server 5.7.13 databases. The following document show results using the 3 drivers with MariaDB Server 10.1.17. For the complete results including the ones with MySQL Server 5.7.13, please see the link at the bottom of the document.

Environment

Execution (client and server) is done on a single server droplet on digitalocean.com using the following parameters:

Java(TM) SE Runtime Environment (build 1.8.0_101-b13) 64bits (actual last version when running this benchmark) Ubuntu 16.04 64bits 512Mb memory 1 CPU database MariaDB "10.1.17-MariaDB", MySQL Community Server build "5.7.15-0ubuntu0.16.04.1"
using default configuration files and these additional options : max_allowed_packet = 40M #exchange packet can be up to 40mb character-set-server = utf8 #to use UTF-8 as default collation-server = utf8_unicode_ci #to use UTF-8 as default

When indicated "distant", benchmarks are runs with separate client and server on 2 identical hosts on same datacenter with an average ping of 0.350ms.

Results sample explanations Benchmark Score Error Units BenchmarkSelect1RowPrepareText.mariadb 62.715 ± 2.402 s/op BenchmarkSelect1RowPrepareText.mysql 88.670 ± 3.505 s/op BenchmarkSelect1RowPrepareText.drizzle 78.672 ± 2.971 s/op x MariaDB-1.5.3 MySQL-5.1.39 Drizzle-1.4 Using text protocol 62.715 88.67 78.672

This means that query SELECT ? will take an average time of 62.715 microseconds using the MariaDB driver with a variation of ± 2.402 microseconds for 99.9% of queries.

Same execution using drizzle driver will take an average time of 88.670 microseconds, and 78.672 microseconds using MySQL connector(smaller execution time the better).

Displayed percentages are set according to the mariadb first result as reference (100%), permitting to easily compare other results.

Performance comparisons The benchmark will test the performances of the 3 main different behaviour using a same local database (same server), and a distant database (another identical server) on same datacenter with an average ping of 0.450ms

Different behaviours:

Text protocol

This corresponds to option useServerPrepStmts disabled.

Queries are sent directly to the server with sanitized parameters replacement done on client side.

Data is sent like text. Example: A timestamp will be sent like text "1970-01-01 00:00:00.000500" using 26 bytes

Binary protocol

This corresponds to the option useServerPrepStmts enabled (default implementation on MariaDB driver).

Data is sent in binary. Example timestamp "1970-01-01 00:00:00.000500" will be sent using 11 bytes.

There are up to 3 exchanges with the server for one query :

PREPARE - Prepares statement for execution. EXECUTE - Send parameters DEALLOCATE PREPARE - Releases a prepared statement. See Server prepare documentation

for more information.

PREPARE results are stored in cache on driver side (default size 250). If Prepare is already in cache, PREPARE will not be executed, DEALLOCATE will be executed only when PREPARE

本文数据库(mysql)相关术语:navicat for mysql mysql workbench mysql数据库 mysql 存储过程 mysql安装图解 mysql教程 mysql 管理工具

主题: JavaSQLMySQLCPUUbuntuUTEPACUSQL ServerJIT
分页:12
转载请注明
本文标题:MariaDB Java Connector Driver Performance
本站链接:http://www.codesec.net/view/480204.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(mysql) | 评论(0) | 阅读(45)