perf: complete industry-standard optimization for frontend & backend

This commit is contained in:
Shanmuga Krishnan S M
2026-08-20 10:18:55 +05:30
parent 128e033a9a
commit 95c97e81fa
6 changed files with 253 additions and 84 deletions

View File

@@ -45,8 +45,17 @@ public class BusLocationService {
public List<BusLocation> getActiveLocations() {
Instant threshold = Instant.now().minus(STALE_DURATION);
// Clean up stale entries on read
return locationCache.values().stream()
.filter(loc -> !loc.getLastUpdated().isBefore(threshold))
.toList();
}
/**
* Periodic background eviction of stale GPS coordinates every 5 minutes
*/
@org.springframework.scheduling.annotation.Scheduled(fixedRate = 300000)
public void evictStaleLocations() {
Instant threshold = Instant.now().minus(STALE_DURATION);
locationCache.entrySet().removeIf(entry -> entry.getValue().getLastUpdated().isBefore(threshold));
return List.copyOf(locationCache.values());
}
}

View File

@@ -3,14 +3,24 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/rit_freshers_hub?sslmode=
spring.datasource.username=postgres
spring.datasource.password=${DB_PASSWORD:Amudiesh22@.}
# ─── HIKARICP CONNECTION POOL OPTIMIZATIONS ───
spring.datasource.hikari.maximum-pool-size=30
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.idle-timeout=300000
spring.datasource.hikari.max-lifetime=1200000
spring.datasource.hikari.connection-timeout=20000
# ─── JPA / HIBERNATE SETTINGS ───
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.format_sql=false
# ─── SERVER PORT ───
# ─── SERVER PORT & HTTP GZIP COMPRESSION ───
server.port=8085
server.compression.enabled=true
server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css
server.compression.min-response-size=1024
# ─── GOOGLE OAUTH2 CONFIGURATION ───
google.client.id=${GOOGLE_CLIENT_ID:81935488244-vmab5t8fipfof1n6l7di7eg4fve6k8lf.apps.googleusercontent.com}
@@ -23,10 +33,8 @@ admin.super.password=${SUPER_ADMIN_PASSWORD:RIT@2026}
admin.username=${ADMIN_USERNAME:ritadmin}
admin.password=${ADMIN_PASSWORD:ritadmin2026}
# ─── IMS INTEGRATION CONFIGURATION ───
# Options: "mock" (active now for testing & simulation) | "real" (for live college IMS)
ims.client.type=mock
ims.base-url=${IMS_BASE_URL:https://api.ims.ritchennai.edu.in}
ims.api-key=${IMS_API_KEY:rit_nexus_vps_secret_key_2026}