mysql-native: preview2

Chris Wright via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Feb 2 08:53:53 PST 2017


On Thu, 02 Feb 2017 06:50:34 +0000, Suliman wrote:

> On Thursday, 2 February 2017 at 05:28:10 UTC, Nick Sabalausky wrote:
>> Made a couple more long-needed changes while I'm at it:
>>
>> https://github.com/Abscissa/mysql-native-experimental Tag:
>> v0.2.0-preview2
>>
>> - For better clarity, renamed `mysql.db.MysqlDB` to
>> `mysql.pool.MySqlPool`.
>>
>> - Package mysql.connection no longer acts as a package.d,
>> publicly importing other modules. To import all of mysql-native, use
>> `import mysql;`
> 
> Thanks! Could you explain about pool. I googled about it, and still
> can't understand when it up new connections?

A database connection is just a socket.

Problem 1: database connections are expensive to set up. (Network 
connections in general are expensive -- in my testing, an AWS EC2 t2.micro 
instance can handle ~80 connections per second. I was primarily testing 
RPC / REST API systems, which is a fair bit more than 'open a socket, send 
a byte, receive a byte, close the socket'.)

Problem 2: database connections only offer one stream of data each 
direction.

Problem 3: my application needs to handle a bunch of requests that might 
occur at the same time, each of which talks to the database.

Solution: we'll have an object that manages a set of connections. It can 
reuse a connection, and it guarantees a connection is not reused when a 
previous user is still using it. It might automatically close a connection 
after enough time without that connection being used. It will 
automatically open a new connection when it has no free connections to 
hand out.


More information about the Digitalmars-d-announce mailing list