Skip to content

Commit c63fc12

Browse files
committed
Redirect o new org.
1 parent 7753faf commit c63fc12

File tree

91 files changed

+1
-15886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1
-15886
lines changed

README.md

Lines changed: 1 addition & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1 @@
1-
# OJP - Open JDBC Proxy
2-
3-
A JDBC driver and proxy server to decouple applications from relational database connection management.
4-
5-
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://buymeacoffee.com/wqoejbve8z)
6-
7-
## Questions we aim to answer:
8-
#### How to autoscale our applications without overloading our relational database(s) with new connections?
9-
#### How to replace native JDBC drivers seamlessly?
10-
#### How to support multiple relational databases at once?
11-
12-
## High Level Design
13-
14-
### [Architectural decision records (ADRs)](documents/ADRs)
15-
16-
<img src="documents/designs/ojp_high_level_design.png" alt="OJP High Level Design" />
17-
18-
19-
* The OJB JDBC driver is used as a replacement for the native JDBC driver(s) previously used with minimum change, the only change required being prefixing the connection URL with ojp_. For example:
20-
```
21-
ojp_[localhost:1059]postgresql://user@localhost
22-
```
23-
instead of:
24-
```
25-
postgresql://user@localhost
26-
```
27-
* **Open Source**: OJP is an open-source project that is free to use, modify, and distribute.
28-
* The OJP server is deployed as an independent service sitting and will serve as a smart proxy between the application(s) and their respective relational database(s) controlling the number of connections open against each database.
29-
* **Smart Connection Management***: The proxy ensures that database connections are allocated only when needed, improving scalability and resource utilization. In example below, only when executeQuery is called a real connection is enlisted to execute the operation, reducing the time that connection is hold and allowing for it to be used by other clients meanwhile:
30-
```
31-
Connection conn = DriverManager.
32-
getConnection("jdbc:ojp[host:port]_h2:~/test", "sa", "");
33-
34-
java.sql.PreparedStatement psSelect = conn.prepareStatement("select * from test_table where id = ?");
35-
psSelect.setInt(1, 1);
36-
ResultSet resultSet = psSelect.executeQuery(); <--- *Real connection allocation*
37-
38-
...
39-
```
40-
* **Elastic Scalability**: OJP allows client applications to scale elastically without increasing the pressure on the database.
41-
* **GRPC protocol** is used to facilitate the connection of the OJP JDBC Driver and the OJP Proxy Server allowing for efficient data transmission over a multiplex channel.
42-
* OJP Proxy server uses **HikariCP** connection pools to efficiently manage connections.
43-
* OJP supports **multiple relational databases**, in theory it can support any relational database that currently provides a JDBC driver implementation.
44-
* OJP simple setup just requires OJP lib to be in the classpath and the OJP prefix to be added to the connection URL as in jdbc:ojp[host:port]_h2:~/test. where host:port represents the location of the proxy server.
45-
46-
## Vision
47-
Provide a free and open-source solution for a relational database-agnostic proxy connection pool. The project is designed to help efficiently manage database connections in microservices, event-driven architectures, or serverless environments while maintaining high scalability and performance.
48-
49-
## Target problem
50-
In modern architectures, such as microservices, event-driven systems, or serverless (Lambda) architectures, a common issue arises in managing the number of open connections to relational databases. When applications need to elastically scale, they often maintain too many database connections. These connections can be held for longer than necessary, locking resources and making scalability difficult. In some cases, this can lead to excessive resource consumption, placing immense pressure on the database. In extreme scenarios, this can even result in database outages.
51-
52-
## The solution
53-
OJP provides a smart proxy to solve this problem by dynamically managing database connections. Rather than keeping connections open continuously, OJP only allocates real database connections when an operation is performed. The proxy ensures that resources are used efficiently by allocating connections only when truly necessary. For example, a real connection to the database is established only when an actual operation (e.g., a query or update) is performed, thus optimizing resource usage and ensuring better scalability.
54-
This intelligent allocation of connections helps prevent overloading databases and ensures that the number of open connections remains efficient, even during heavy elastic scaling of applications.
55-
56-
## Components
57-
58-
### ojp-server
59-
The ojp-server is a gRPC server that manages a Hikari connection pool and abstracts the creation and management of database connections. It supports one or multiple relational databases and provides virtual connections to the ojp-jdbc-driver. The server ensures the number of open real connections is always under control, according to predefined settings, improving database scalability.
60-
61-
#### How to start a docker image
62-
63-
> docker run --rm -d -p 1059:1059 rrobetti/ojp:0.0.3-alpha
64-
65-
### ojp-jdbc-driver
66-
The ojp-jdbc-driver is an implementation of the JDBC specification. It connects to the ojp-server via the gRPC protocol, sending SQL statements to be executed against the database and reading the responses. The driver works with virtual connections provided by the ojp-server, allowing the application to interact with the database without directly managing real database connections.
67-
68-
### ojp-grpc-commons
69-
The ojp-grpc-commons module contains the shared gRPC contracts used between the ojp-server and ojp-jdbc-driver. These contracts define the communication protocol and structure for requests and responses exchanged between the server and the driver.
70-
71-
## How to build & test
72-
73-
From the root of the project, follow these 3 steps to build and test the project:
74-
75-
### 1. Build modules
76-
77-
``mvn clean install -DskipTests``
78-
79-
### 2. Run ojp-server
80-
81-
This step is required to run tests.
82-
83-
``mvn verify -pl ojp-server -Prun-ojp-server``
84-
85-
### 3. Run tests
86-
Connections configuration: There are csv files under test/resources with connection details defaulted to H2 database, the name of each file implies which database connections can be added to it, for example the file h2_postgres_connections.csv can contain connections to H2 and/or postgres databases, integration tests classes that relly on this file will run all their tests against each connection in the file.
87-
88-
Refer to the [run-local-databases.md](documents/environment-setup/run-local-databases.md) for more details on how to start local databases for testing.
89-
90-
``mvn test``
91-
92-
Optional flags:
93-
- `-DdisablePostgresTests` to skip integration test that require a Postgres database.
94-
95-
## Partners
96-
<a href=https://www.linkedin.com/in/devsjava/>
97-
<img width="150px" height="150px" src="documents/images/comunidade_brasil_jug.jpeg" alt="Comunidade Brasil JUG" />
98-
</a>
99-
<a href=https://github.com/switcherapi>
100-
<img width="180px" src="documents/images/switcherapi_grey.png" alt="Comunidade Brasil JUG" />
101-
</a>
102-
103-
## Feature implementation status
104-
- ✅ Basic CRUD operations.
105-
- ✅ Streamed result set reading.
106-
- ✅ BLOB support.
107-
- ✅ Transactions support.
108-
- ✅ Binary Stream support.
109-
- ✅ ResultSet metadata enquiring.
110-
- ❌ CLOB support.
111-
- ✅ Statement and Prepared statement advanced features.
112-
- ✅ Connection advanced features.
113-
- 🕓 OpenTelemetry implementation.
114-
- ✅ Circuit Breaker.
115-
- ❌ Slow queries segregation.
116-
- ✅ Docker image implementation.
117-
- ❌ Support for Spring Boot/Spring Data.
118-
- ❌ Support for Micronaut.
119-
- ❌ Support for Quarkus.
120-
- ❌ Support for Helidon.
121-
- ❌ BLOB and CLOB advanced features.
122-
- ❌ Configurable data sources by user and/or database.
123-
- ❌ RAFT consensus POC.
124-
- ❌ RAFT and connection smart balancing and resizing.
125-
126-
127-
#### Other feature candidates:
128-
Query Routing, Sharding, Query Caching, Read/Write Splitting, Multi-Cloud/Distributed Clustering, Authentication Integration, Advanced Security Features, Failover and Automatic Replication Awareness
129-
130-
✅ - Done
131-
❌ - Not started
132-
🕓 - In progress
1+
# Moved to https://github.com/Open-JDBC-Proxy/ojp

documents/ADRs/adr-001-use-java.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

documents/ADRs/adr-002-use-grpc.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

documents/ADRs/adr-003-use-hikaricp.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

documents/ADRs/adr-004-implement-jdbc-interface.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

documents/ADRs/adr-005-use-opentelemetry.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)