Wednesday, 9 December 2015

Akka-FTP structural overview

Today I will show you the Akka-FTP architecture and what is going on under its hood. Let's take a bird view onto the overall structure and the flows between the core components. And we will look only at the FTP side of the project, no REST nor UI will be explained in this post.

The big picture

Here it is, every major component fitted nicely into one picture, thaks to Lucidchart! I understand, a bit of explanation is still required. First things first, red boxes are the actors. A user connects to the control connector at the very top, which spawns (creates label on the diagram) a control connection, which in turn creates user's session etc etc. FTP state is the core piece with all the dependencies such as command factory, file system and more. It is directly or indirectly referenced by every other component. Session is specific to a given user. Control connection accepts user's commands and sends replies to the user. Data connection transfers files and when the transfer completes, it notifies the control connection to send a reply. Task executor uses slave actors to handle commands and provide replies back to the control connection.

Command is an FTP command a user sends to the server. It does what it needs and outputs a reply. Reply is then sent back to the user.

The last piece worth explaining is how the data connection gets created. Both data connector and data connection initiator create it. When a user sends a PORT command, the data connection initiator attempts (initiates - hence the name) a connection to the user machine, using the IP address and port supplied. On the other hand, when the user sends a PASV command, the user then needs to make a connection to the data connector. At the moment of this writing, there is no data connector yet thus the PASV command is not supported, but eventually it will be implemented.

Global and user actors

Server eventually creates the following 3 actors for every user: control connection, data connection, data connection initiator. Those actors exist only while the user is connected and die afterwards. The rest of the actors not related to users and exist while the server is running.

Summary

This chapter should help you to understand how the FTP side of the project works. Something that you may need if you want to extend the server with your own addons, otherwise, why would you bother with this project in the first place? Stay tooned for more posts!

No comments:

Post a Comment