{"id":15430544,"url":"https://github.com/lenisha/spring-jdbc-docker","last_synced_at":"2025-11-09T07:30:34.598Z","repository":{"id":42541836,"uuid":"262228822","full_name":"lenisha/spring-jdbc-docker","owner":"lenisha","description":"Java Spring app on AKS and JDBC to Azure SQL","archived":false,"fork":false,"pushed_at":"2022-12-16T01:50:46.000Z","size":50395,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T06:16:07.090Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lenisha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-08T04:44:01.000Z","updated_at":"2022-01-11T15:53:54.000Z","dependencies_parsed_at":"2023-01-29T07:30:52.006Z","dependency_job_id":null,"html_url":"https://github.com/lenisha/spring-jdbc-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fspring-jdbc-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fspring-jdbc-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fspring-jdbc-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fspring-jdbc-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lenisha","download_url":"https://codeload.github.com/lenisha/spring-jdbc-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239571542,"owners_count":19661164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T18:16:51.408Z","updated_at":"2025-11-09T07:30:34.541Z","avatar_url":"https://github.com/lenisha.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring/Hibernate App on Azure AKS (Tomcat) using JNDI to access SQL Server on Azure  \n\nCode for the article posted on dzone: https://dzone.com/articles/migrating-java-applications-to-azure-app-service-p\n\n## Spring Hibernate JNDI Example\n\nThis Spring example is based on tutorial [Hibernate, JPA \u0026 Spring MVC - Part 2] (https://www.alexecollins.com/tutorial-hibernate-jpa-spring-mvc-part-2/) by Alex Collins\n\nSpring application uses hibernate to connect to SQL Server. Hibernate is using container managed JNDI Data Source.\n\nThere are few options to configure JNDI for the web application running undet Tomcat (Tomcat JNDI)[https://www.journaldev.com/2513/tomcat-datasource-jndi-example-java] :\n\n- Application context.xml - located in app `META-INF/context.xml` - define Resource element in the context file and container will take care of loading and configuring it.\n- Server server.xml - Global, shared by applications, defined in `tomcat/conf/server.xml`\n- server.xml and context.xml - defining Datasource globally and including ResourceLink in application context.xml\n\n# Docker\n```\nmvn package -DskipTests\ndocker build -t spring-jdbc-docker .\ndocker tag spring-jdbc-docker lenisha/spring-jdbc-docker\ndocker push lenisha/spring-jdbc-docker\n\ndocker run --rm -it -p 8080:8080 -e JAVA_OPTS=\"$JAVA_OPTS\"  spring-jdbc-docker\n```\n\n```\nexport SQL_URL=\"jdbc:sqlserver://testmetoday.database.windows.net:1433;database=testae;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;\"\nexport SQL_PASSWORD=xxx\nexport SQL_USER=todayadmin@testmetoday\nexport JAVA_OPTS=\"-DSQL_URL='$SQL_URL' -DSQL_USER=$SQL_USER -DSQL_PASSWORD=$SQL_PASSWORD\"\n\n```\n\n# K8S\n\n- Create Secrets for SQL and AppDynamics and ConfigMap for `logging.properties` for JDBC logs\n```\nkubectl create secret generic sqlpass --from-literal=SQL_PASS=xxxx\n\nkubectl create secret generic appdynamicspass --from-literal=APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY=XXXX\n\nkubectl apply -f ./\n```\n\n\n```\ncurl http://51.143.109.195/spring-jdbc-docker/users.html\n```\n\n# LOAD TEST\nLoad testing done using utility `hey` and docker image with script running as ACI group in a different region.\n\n```\naz container create -g jogardn-aks -n loadtestspringget --location westus --image lenisha/loadtest-spring:latest --restart-policy Always -e SERVICE_ENDPOINT=http://51.143.109.195/spring-jdbc-docker/users.html\n\naz container logs -g jogardn-aks -n loadtestspringget\naz container start -g jogardn-aks -n loadtestspringget\n\naz container delete -g jogardn-aks -n loadtestspringget\n\naz container create -g jogardn-aks -n loadtestspringpost --location westus --image lenisha/loadtest-spring:latest --restart-policy Never -e SERVICE_ENDPOINT=http://51.143.109.195/spring-jdbc-docker/create-user.html --command-line '/app/loadtest-post.sh'\n\n\naz container logs -g jogardn-aks -n loadtestspringpost\naz container delete -g jogardn-aks -n loadtestspringpost\n```\n\n### Artillery Load test\n\n```\nnpm install -g artillery\nartillery quick --count 10 -n 20 http://51.143.109.195/spring-jdbc-docker/users100.html\n```\n\n\n### Results\n\nWith only one pod in replicaset Tomcat starts to queue up pretty quickly\n```\nPhase 3: Load test - 30 seconds, 1600 users.\nDetails (average, fastest, slowest):\n  DNS+dialup:   0.7815 secs, 0.9255 secs, 20.0002 secs\n  DNS-lookup:   0.0000 secs, 0.0000 secs, 0.0000 secs\n  req write:    0.0002 secs, 0.0000 secs, 0.0092 secs\n  resp wait:    0.4542 secs, 0.0540 secs, 3.9736 secs\n  resp read:    0.0262 secs, 0.0000 secs, 0.3960 secs\n\nStatus code distribution:\n  [200] 3050 responses\n\nError distribution:\n  [988] Get \"http://51.143.109.195/spring-jdbc-docker/users.html\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)      \n  [401] Get \"http://51.143.109.195/spring-jdbc-docker/users.html\": dial tcp 51.143.109.195:80: i/o timeout (Client.Timeout exceeded while awaiting \nheaders)\n\nWaiting 15 seconds for the cluster to stabilize\n\\nPhase 4: Load test - 30 seconds, 3200 users.\n\nSummary:\n  Total:        49.6588 secs\n  Slowest:      20.0003 secs\n  Fastest:      0.8639 secs\n  Average:      10.3038 secs\n  Requests/sec: 156.9511\n\n\nResponse time histogram:\n  0.864 [1]     |\n  2.778 [205]   |■■■■■■■■■■■■■■■■■■■\n  4.691 [367]   |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■\n  6.605 [348]   |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■\n  8.518 [346]   |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■\n  10.432 [187]  |■■■■■■■■■■■■■■■■■■\n  12.346 [247]  |■■■■■■■■■■■■■■■■■■■■■■■\n  14.259 [275]  |■■■■■■■■■■■■■■■■■■■■■■■■■■\n  16.173 [133]  |■■■■■■■■■■■■■\n  18.087 [185]  |■■■■■■■■■■■■■■■■■■\n  20.000 [421]  |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■\n\n\nLatency distribution:\n  10% in 3.1229 secs\n  25% in 5.0198 secs\n  50% in 9.4596 secs\n  75% in 15.3072 secs\n  90% in 19.1711 secs\n  95% in 19.7091 secs\n  99% in 19.9749 secs\n```\n\n\nWith 20 pods timeouts start to happen later  with more load:\n\n```\nWaiting 15 seconds for the cluster to stabilize\n\\nPhase 4: Load test - 30 seconds, 3200 users.\n\nSummary:\n  Total:        40.2460 secs\n  Slowest:      13.6339 secs\n  Fastest:      0.7814 secs\n  Average:      8.7992 secs\n  Requests/sec: 312.1556\n\n\nResponse time histogram:\n  0.781 [1]     |\n  2.067 [375]   |■■\n  3.352 [248]   |■\n  4.637 [255]   |■■\n  5.922 [482]   |■■■\n  7.208 [490]   |■■■\n  8.493 [620]   |■■■■\n  9.778 [6686]  |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■\n  11.063 [2728] |■■■■■■■■■■■■■■■■\n  12.349 [611]  |■■■■\n  13.634 [67]   |\n\n\nLatency distribution:\n  10% in 5.6709 secs\n  25% in 8.7648 secs\n  50% in 9.3146 secs\n  75% in 9.8826 secs\n  90% in 10.6724 secs\n  95% in 11.1127 secs\n  99% in 12.0760 secs\n\nDetails (average, fastest, slowest):\n  DNS+dialup:   0.0438 secs, 0.7814 secs, 13.6339 secs\n  DNS-lookup:   0.0000 secs, 0.0000 secs, 0.0000 secs\n  req write:    0.0005 secs, 0.0000 secs, 0.0216 secs\n  resp wait:    2.9225 secs, 0.0252 secs, 9.8454 secs\n  resp read:    0.1482 secs, 0.0000 secs, 1.5621 secs\n\nStatus code distribution:\n  [200] 12203 responses\n  [500] 360 responses\n\n\n\nWaiting 15 seconds for the cluster to stabilize\n\\nPhase 5: Load test - 30 seconds, 6400 users.\n\nSummary:\n  Total:        49.8169 secs\n  Slowest:      20.0157 secs\n  Fastest:      0.0502 secs\n  Average:      13.8072 secs\n  Requests/sec: 335.8497\n\n\nResponse time histogram:\n  0.050 [1]     |\n  2.047 [597]   |■■■■■\n  4.043 [440]   |■■■\n  6.040 [891]   |■■■■■■■\n  8.036 [840]   |■■■■■■■\n  10.033 [1222] |■■■■■■■■■■\n  12.029 [672]  |■■■■■\n  14.026 [763]  |■■■■■■\n  16.023 [641]  |■■■■■\n  18.019 [1792] |■■■■■■■■■■■■■■\n  20.016 [5101] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■\n\n\nLatency distribution:\n  10% in 4.5961 secs\n  25% in 8.6647 secs\n  50% in 16.3987 secs\n  75% in 19.2860 secs\n  90% in 19.6592 secs\n  95% in 19.8914 secs\n  99% in 20.0002 secs\n\nDetails (average, fastest, slowest):\n  DNS+dialup:   0.6993 secs, 0.0502 secs, 20.0157 secs\n  DNS-lookup:   0.0000 secs, 0.0000 secs, 0.0000 secs\n  req write:    0.0024 secs, 0.0000 secs, 0.1609 secs\n  resp wait:    1.6802 secs, 0.0255 secs, 7.9628 secs\n  resp read:    0.2702 secs, 0.0000 secs, 5.3113 secs\n\nStatus code distribution:\n  [200] 11368 responses\n  [500] 1592 responses\n\nError distribution:\n  [2406]        Get \"http://51.143.109.195/spring-jdbc-docker/users.html\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)\n  [1365]        Get \"http://51.143.109.195/spring-jdbc-docker/users.html\": dial tcp 51.143.109.195:80: i/o timeout (Client.Timeout exceeded while awaiting headers)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenisha%2Fspring-jdbc-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flenisha%2Fspring-jdbc-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenisha%2Fspring-jdbc-docker/lists"}