Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfcc6d7ffe | ||
|
|
488bb99c1a | ||
|
|
dcbcabbe4d | ||
|
|
fe5701e798 | ||
|
|
74cebb7766 | ||
|
|
0d65b76a1a | ||
|
|
83ac570592 | ||
|
|
ded5349998 | ||
|
|
67b520ae08 | ||
|
|
eb59e29dc8 | ||
|
|
0b8527dbd8 | ||
|
|
3e29ecba97 | ||
|
|
e1359b7958 | ||
|
|
32dcb3a21b | ||
|
|
42efaf9cf1 | ||
|
|
83a4bf7817 | ||
|
|
8d1a25466d | ||
|
|
8231aa658d | ||
|
|
dc13af31b0 | ||
|
|
95cfd6b574 | ||
|
|
88a316dda6 | ||
|
|
75329f85f5 | ||
|
|
25599780dd | ||
|
|
51d724c1db | ||
|
|
41f869a287 | ||
|
|
a224b16f24 | ||
|
|
caa4add86a | ||
|
|
b48748b462 | ||
|
|
d53a195986 | ||
|
|
4d2fece46d | ||
|
|
ee379ee251 | ||
|
|
81c49eef16 | ||
|
|
ff3a382a0e | ||
|
|
e213d99cf2 | ||
|
|
10c4aa8831 |
@@ -0,0 +1,14 @@
|
||||
name: Quiz App Deployment
|
||||
run-name: ${{ gitea.actor }} is deploying Quiz App
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
Quiz Runner:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- run: docker compose up -d --build
|
||||
@@ -0,0 +1,13 @@
|
||||
name: Quiz App Testing
|
||||
run-name: ${{ gitea.actor }} is testing Quiz App
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Quiz Runner:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: docker --version
|
||||
- run: docker compose version
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
# Run tests
|
||||
+31
-6
@@ -1,20 +1,20 @@
|
||||
# Issues
|
||||
# Reflection
|
||||
|
||||
## Issues during testing
|
||||
## Issues during testing (October 30th)
|
||||
### Scheduler
|
||||
I don't know if it was the scheduler specifically, but whenever I try to test it, both the cache and the queue seem to become empty after the first function is completed.
|
||||
I don't know how to solve this yet
|
||||
|
||||
|
||||
## Caching solution
|
||||
## Caching solution (October 30th)
|
||||
### Lack of data
|
||||
Not being able to gather blocks of 50 is a huge issue. The idea of reusing blocks becomes less viable if I can just get a big chunk every time for others to use
|
||||
Not being able to gather blocks of 50 is a big issue. The idea of reusing blocks becomes less viable if I can't just get a big chunk every time for others to use.
|
||||
I can't force a big chunk, because it might just return a status 1, and then the user gets nothing.
|
||||
|
||||
Perhaps I can separate the questions myself and make a collection, that i can build the requests from. However, for every quest tracking if someone has already seen is a huge pain.
|
||||
|
||||
|
||||
## Possible solution
|
||||
## Possible solution (October 31st)
|
||||
Cache all data, 50 at a time
|
||||
Store it in a database
|
||||
When its done, let the db make blocks for quick cache access
|
||||
@@ -28,7 +28,7 @@ Then start replacing the cache items one at a time.
|
||||
|
||||
Users shouldn't feel this at all, because the active sessions are stored in their own cache items
|
||||
|
||||
# Progress so far
|
||||
# Progress so far (November 3rd)
|
||||
There only seem to be ~4100 items, making the collecting phase only last around 7 minutes.
|
||||
|
||||
Swapping dbs is replaced with swapping tables, seems to work just as fine, yet much simpler to set up
|
||||
@@ -36,3 +36,28 @@ Swapping dbs is replaced with swapping tables, seems to work just as fine, yet m
|
||||
TODO: Add a caching state, and start filling up each unique combination with the items from the db
|
||||
This should lead to performance gains
|
||||
|
||||
## Possible future alternative
|
||||
In the current state (when the cache is done), the backend might hold data 3 times (Cache, active DB table, and background DB table during the night)
|
||||
|
||||
### Purely Cached solution
|
||||
- Every night
|
||||
- Check for each category+difficulty combination how many questions there are (API has an endpoint for this)
|
||||
- Track which one you are on, and how many you have
|
||||
- Take blocks of 50, until the remaining items are less than 50, then get that exact amount
|
||||
- When they are gathered, either
|
||||
1. Divide them between 3 cache items: cat:dif:any/multiple/boolean
|
||||
- (Manually filter on the type, since the API sends questions with either option together), or
|
||||
2. In one like cat:dif:any and then filter it by hand when a user asks for it
|
||||
- (This will replace the collection put there the night before)
|
||||
- Then move to the next one
|
||||
- Stop when the last combination has been collected
|
||||
|
||||
#### When a user requests data:
|
||||
- Get the items from the cache
|
||||
- Less items than requested: Inform the user to try a different combination
|
||||
- More items than requested: Randomize and select a subset
|
||||
|
||||
### Tradeoffs
|
||||
- Advantage: Less total data held on the server
|
||||
|
||||
- Downside: Slower gathering, since there are 25+3+4=300 unique combinations (each of which will end with a request of less than 50 items), it will require a decent number requests more than the bulk collecting that the DB does.
|
||||
@@ -12,7 +12,7 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**") // Allow all endpoints
|
||||
.allowedOrigins("http://localhost:4200") // Allow specific origin
|
||||
.allowedOrigins("http://localhost:4200", "https://quiz.ianvink.nl") // Allow specific origin
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // Allow specific methods
|
||||
.allowedHeaders("*") // Allow all headers
|
||||
.allowCredentials(true); // Allow credentials
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
spring.application.name=quiz
|
||||
server.address=0.0.0.0
|
||||
server.port=9090
|
||||
|
||||
# H2 Database configuration
|
||||
|
||||
+14
-1
@@ -8,6 +8,11 @@ services:
|
||||
container_name: quiz-frontend-prod-cont
|
||||
ports:
|
||||
- "4200:80"
|
||||
networks:
|
||||
- quiz-network
|
||||
restart: always
|
||||
cpu_period: 100000 # Default is 100,000 microseconds (100ms)
|
||||
cpu_quota: 5000 # 5% of the total CPU time
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
@@ -16,4 +21,12 @@ services:
|
||||
image: quiz-backend-prod
|
||||
container_name: quiz-backend-prod-cont
|
||||
ports:
|
||||
- "9090:9090"
|
||||
- "9090:9090"
|
||||
networks:
|
||||
- quiz-network
|
||||
restart: always
|
||||
cpu_period: 100000 # Default is 100,000 microseconds (100ms)
|
||||
cpu_quota: 5000 # 5% of the total CPU time
|
||||
|
||||
networks:
|
||||
quiz-network: # Define the network
|
||||
@@ -27,5 +27,6 @@ RUN ng build --configuration production
|
||||
#--- Production
|
||||
FROM nginx:alpine AS production
|
||||
COPY --from=build /app/dist/quiz/browser /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
@@ -0,0 +1,61 @@
|
||||
server {
|
||||
listen 80;
|
||||
# server_name quiz.ianvink.nl;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_set_header Connection '';
|
||||
proxy_http_version 1.1;
|
||||
proxy_read_timeout 360s;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
# add_header 'Access-Control-Allow-Origin' '*'; # Adjust this to your frontend domain
|
||||
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # Include POST
|
||||
# add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization'; # Include any other headers
|
||||
|
||||
proxy_pass http://backend:9090/;
|
||||
}
|
||||
}
|
||||
|
||||
# server {
|
||||
# listen 80;
|
||||
# server_name quiz.ianvink.nl;
|
||||
|
||||
# location /.well-known/acme-challenge/ {
|
||||
# root /usr/share/nginx/html; # Adjust this if needed
|
||||
# }
|
||||
|
||||
# location / {
|
||||
# return 301 https://$host$request_uri;
|
||||
# }
|
||||
# }
|
||||
|
||||
# server {
|
||||
# listen 443 ssl;
|
||||
# server_name quiz.example.com;
|
||||
|
||||
# ssl_certificate /etc/letsencrypt/live/quiz.example.com/fullchain.pem;
|
||||
# ssl_certificate_key /etc/letsencrypt/live/quiz.example.com/privkey.pem;
|
||||
|
||||
# location / {
|
||||
# root /usr/share/nginx/html;
|
||||
# index index.html;
|
||||
# try_files $uri $uri/ /index.html;
|
||||
# }
|
||||
|
||||
# location /api/ {
|
||||
# proxy_pass http://backend:9090/; # Adjust this if needed
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# proxy_set_header X-Forwarded-Proto $scheme;
|
||||
# }
|
||||
# }
|
||||
@@ -32,4 +32,4 @@
|
||||
Start Quiz
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,5 +2,6 @@ export const environment = {
|
||||
production: true,
|
||||
/** Connecting through the docker compose network is not working for now, so I'll have to use the localhost */
|
||||
// apiUrl: 'http://backend:9090',
|
||||
apiUrl: 'http://localhost:9090',
|
||||
apiUrl: '/api' //'https://api.nosotros.ianvink.nl',
|
||||
// apiUrl: 'http://localhost:9090',
|
||||
};
|
||||
Reference in New Issue
Block a user