Skip to content

Commit

Permalink
changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
aadhavanpl committed Apr 10, 2024
1 parent 1b4d498 commit a0d3d12
Show file tree
Hide file tree
Showing 26 changed files with 1,545 additions and 1,513 deletions.
40 changes: 22 additions & 18 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ export default defineConfig({
link: '/roadmap/phase-0/stage-3',
},
{
text: 'Stage 4: TCP proxy',
text: 'Stage 4: UDP server with multi-threading',
link: '/roadmap/phase-0/stage-4',
},
{
text: 'Stage 5: TCP proxy',
link: '/roadmap/phase-0/stage-5',
},
],
},
{
Expand All @@ -106,23 +110,23 @@ export default defineConfig({
link: '/roadmap/phase-1/',
},
{
text: 'Stage 5: Server & Client module',
text: 'Stage 6: Server & Client module',
link: '/roadmap/phase-1/stage-5',
},
{
text: 'Stage 6: Core & Loop module',
text: 'Stage 7: Core & Loop module',
link: '/roadmap/phase-1/stage-6',
},
{
text: 'Stage 7: TCP module',
text: 'Stage 8: TCP module',
link: '/roadmap/phase-1/stage-7',
},
{
text: 'Stage 8: Upstream module',
text: 'Stage 9: Upstream module',
link: '/roadmap/phase-1/stage-8',
},
{
text: 'Stage 9: File module',
text: 'Stage 10: File module',
link: '/roadmap/phase-1/stage-9',
},
],
Expand All @@ -136,19 +140,19 @@ export default defineConfig({
link: '/roadmap/phase-2/',
},
{
text: 'Stage 10: HTTP parser',
text: 'Stage 11: HTTP parser',
link: '/roadmap/phase-2/stage-10',
},
{
text: 'Stage 11: HTTP req & HTTP res',
text: 'Stage 12: HTTP req & HTTP res',
link: '/roadmap/phase-2/stage-11',
},
{
text: 'Stage 12: Config & Session module',
text: 'Stage 13: Config & Session module',
link: '/roadmap/phase-2/stage-12',
},
{
text: 'Stage 13: HTTP Spec',
text: 'Stage 14: HTTP Spec',
link: '/roadmap/phase-2/stage-13',
},
],
Expand All @@ -162,23 +166,23 @@ export default defineConfig({
link: '/roadmap/phase-3/',
},
{
text: 'Stage 14: IP whitelist & blacklist',
text: 'Stage 15: IP whitelist & blacklist',
link: '/roadmap/phase-3/stage-14',
},
{
text: 'Stage 15: Directory browsing',
text: 'Stage 16: Directory browsing',
link: '/roadmap/phase-3/stage-15',
},
{
text: 'Stage 16: Compression',
text: 'Stage 17: Compression',
link: '/roadmap/phase-3/stage-16',
},
{
text: 'Stage 17: Load balancing',
text: 'Stage 18: Load balancing',
link: '/roadmap/phase-3/stage-17',
},
{
text: 'Stage 18: Rate limiting & timeouts',
text: 'Stage 19: Rate limiting & timeouts',
link: '/roadmap/phase-3/stage-18',
},
],
Expand All @@ -192,15 +196,15 @@ export default defineConfig({
link: '/roadmap/phase-4/',
},
{
text: 'Stage 19: TLS',
text: 'Stage 20: TLS',
link: '/roadmap/phase-4/stage-19',
},
{
text: 'Stage 20: Caching',
text: 'Stage 21: Caching',
link: '/roadmap/phase-4/stage-20',
},
{
text: 'Stage 21: Multiprocess Architecture',
text: 'Stage 22: Multiprocess Architecture',
link: '/roadmap/phase-4/stage-21',
},
],
Expand Down
3 changes: 2 additions & 1 deletion docs/roadmap/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ The eXpServer project comprises 22 stages, organized into 5 phases. Prior to the
- [Stage 1: TCP Server](phase-0/stage-1)
- [Stage 2: TCP Client](phase-0/stage-2)
- [Stage 3: Linux epoll](phase-0/stage-3)
- [Stage 4: TCP Proxy](phase-0/stage-4)
- [Stage 4: UDP with Multi-threading](phase-0/stage-4)
- [Stage 5: TCP Proxy](phase-0/stage-5)

### Phase 1: Building the core of eXpServer by creating reusable modules

Expand Down
28 changes: 16 additions & 12 deletions docs/roadmap/phase-0/stage-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ hello
olleh
```

## Exercises
## Experiments

### Exercise #1
### Experiment #1

What would happen when multiple clients try and connect to the same server? Let us test it out!

Expand All @@ -188,23 +188,27 @@ Meanwhile, client #1 remains connected. To verify the connection, we can send an

Think of why this is happening. We will fix it in the next stage.

### Exercise #2
### Experiment #2

Did you notice how the server closed when the client disconnected?
Did you notice what happened when you closed the connected client instance? The sever also terminated with it. But what if the server wants to keep serving other clients?

TODO
Modify the code such that the server does not terminate immedietly after a client disconnects.

Ask them to fix the issue

Test cases to test the code
::: info HINT
Changes are needed where the server accepts the client connection using `accept()`.
:::

## Conclusion

Congratulations! You have written a TCP client from the ground up which connected with a TCP server with the ability to send and receive messages.

There are two methods to solve the above problem:
Recall the problem from [Experiment #1](/roadmap/phase-0/stage-2#experiment-1). This limitation can be fixed using using two different methods:

1. With [multi-threading](<https://en.wikipedia.org/wiki/Multithreading_(computer_architecture)>)
2. With [epoll](https://en.wikipedia.org/wiki/Epoll)

In web severs like [Apache](https://en.wikipedia.org/wiki/Apache_HTTP_Server), multi-threading was used for serving clients simultaneously. Each incoming client request is typically assigned to a separate thread, allowing the server to serve multiple clients concurrently without blocking or slowing down other requests.

1. With threading
2. With epoll
Whereas in [Nginx](https://en.wikipedia.org/wiki/Nginx), a more recent web server compared to Apache, uses an event-driven architecture, which relies on epoll. Instead of creating a new thread for every new connection, a single thread is sufficient to handle multiple clients simultaneously.

In the next stage we will work with threading.
In the next stage we will build a server with multi-threading to solve the cuncurrency issue.
Loading

0 comments on commit a0d3d12

Please sign in to comment.