kukuy 1.5.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -188
- package/balancer.log +30 -0
- package/certs/auto/certificate.crt +22 -0
- package/certs/auto/private.key +28 -0
- package/kukuy-plugins/README.md +125 -0
- package/kukuy-plugins/cache-plugin/index.js +477 -0
- package/kukuy-plugins/cache-plugin/manifest.json +17 -0
- package/kukuy-plugins/ejemplo-plugin/index.js +41 -0
- package/kukuy-plugins/ejemplo-plugin/manifest.json +11 -0
- package/kukuy-plugins/health-checker/index.js +168 -0
- package/kukuy-plugins/health-checker/manifest.json +16 -0
- package/kukuy-plugins/health-monitor/index.js +58 -0
- package/kukuy-plugins/health-monitor/manifest.json +16 -0
- package/kukuy-plugins/redirect-plugin/index.js +172 -0
- package/kukuy-plugins/redirect-plugin/manifest.json +15 -0
- package/package.json +7 -3
- package/servers_real.json +5 -0
- package/src/core/Balancer.js +176 -39
- package/src/core/ServerPool.js +2 -2
- package/src/extensibility/ExtendedFilterChain.js +90 -0
- package/src/extensibility/ExtendedHookManager.js +87 -0
- package/src/extensibility/FilterChain.js +2 -9
- package/src/extensibility/HookManager.js +1 -0
- package/src/extensibility/PostStartupExtension.js +97 -0
- package/src/plugins/PluginManager.js +231 -0
- package/src/utils/HealthChecker.js +61 -6
- package/.ctagsd/ctagsd.json +0 -954
- package/.ctagsd/file_list.txt +0 -100
- package/.ctagsd/tags.db +0 -0
- package/CHANGELOG.md +0 -125
- package/LICENSE +0 -680
- package/README-SSL.md +0 -165
- package/captura.png +0 -0
- package/kukuu1.webp +0 -0
- package/kukuy.workspace +0 -11
- package/optimize-mariadb.sh +0 -152
- package/restart-balancer.sh +0 -10
- package/scripts/load_test.py +0 -151
- package/stress-test.js +0 -190
- package/test_optimization.js +0 -54
package/test_optimization.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const { RoundRobinAlgorithm } = require('./src/algorithms/RoundRobinAlgorithm');
|
|
2
|
-
const { IPHashAlgorithm } = require('./src/algorithms/IPHashAlgorithm');
|
|
3
|
-
const { ServerPool } = require('./src/core/ServerPool');
|
|
4
|
-
|
|
5
|
-
// Crear instancias de prueba
|
|
6
|
-
const roundRobin = new RoundRobinAlgorithm();
|
|
7
|
-
const ipHash = new IPHashAlgorithm();
|
|
8
|
-
const serverPool = new ServerPool();
|
|
9
|
-
|
|
10
|
-
// Agregar servidores de prueba
|
|
11
|
-
const servers = [
|
|
12
|
-
{ url: 'http://server1.com', weight: 1, tags: ['api'] },
|
|
13
|
-
{ url: 'http://server2.com', weight: 1, tags: ['api'] },
|
|
14
|
-
{ url: 'http://server3.com', weight: 1, tags: ['web'] }
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
serverPool.addServers(servers);
|
|
18
|
-
|
|
19
|
-
console.log('Prueba de optimización del balanceador Kukuy');
|
|
20
|
-
console.log('============================================');
|
|
21
|
-
|
|
22
|
-
// Probar Round Robin
|
|
23
|
-
console.log('\n1. Prueba de Round Robin:');
|
|
24
|
-
const healthyServers = serverPool.getHealthyServers();
|
|
25
|
-
for (let i = 0; i < 5; i++) {
|
|
26
|
-
const server = roundRobin.selectServer(healthyServers);
|
|
27
|
-
console.log(`Solicitud ${i+1}: Servidor seleccionado - ${server.url}`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Probar IP Hash
|
|
31
|
-
console.log('\n2. Prueba de IP Hash:');
|
|
32
|
-
const requestContext1 = { req: { headers: { 'x-forwarded-for': '192.168.1.10' } } };
|
|
33
|
-
const requestContext2 = { req: { headers: { 'x-forwarded-for': '192.168.1.11' } } };
|
|
34
|
-
|
|
35
|
-
const server1 = ipHash.selectServer(healthyServers, requestContext1);
|
|
36
|
-
const server2 = ipHash.selectServer(healthyServers, requestContext1); // Misma IP
|
|
37
|
-
const server3 = ipHash.selectServer(healthyServers, requestContext2); // Distinta IP
|
|
38
|
-
|
|
39
|
-
console.log(`IP 192.168.1.10 primera vez: ${server1.url}`);
|
|
40
|
-
console.log(`IP 192.168.1.10 segunda vez: ${server2.url}`);
|
|
41
|
-
console.log(`IP 192.168.1.11 primera vez: ${server3.url}`);
|
|
42
|
-
console.log(`Misma IP usa mismo servidor: ${server1.id === server2.id ? 'Sí' : 'No'}`);
|
|
43
|
-
|
|
44
|
-
// Probar eficiencia de acceso a servidores
|
|
45
|
-
console.log('\n3. Prueba de eficiencia de acceso a servidores:');
|
|
46
|
-
const startTime = process.hrtime.bigint();
|
|
47
|
-
const taggedServers = serverPool.getServersByTag('api');
|
|
48
|
-
const endTime = process.hrtime.bigint();
|
|
49
|
-
const duration = Number(endTime - startTime) / 1000000; // Convertir a milisegundos
|
|
50
|
-
|
|
51
|
-
console.log(`Servidores con tag 'api': ${taggedServers.length}`);
|
|
52
|
-
console.log(`Tiempo de acceso: ${duration} ms`);
|
|
53
|
-
|
|
54
|
-
console.log('\n¡Todas las pruebas básicas pasaron!');
|