تماشای این درس نیاز به اشتراک حرفه‌ای دارد.

Creating a Jump Box0:58

Weber will take some time to provision the database. And I'll use the power of video editing to skip all this waiting. And here we go. The database is active. Let's head over to the network section, choose the network we created the database inside. And notice that this network has a NAT gateway configured. Now let's scroll down until we see a section called jump boxes. Let's create one, name it Laracasts, and hit create. Weber displays the private key we will use to connect this to this jump box from our machine. Now let's copy that and store it somewhere. Then we close the window, head back to the databases section, select our database. And now we have the hostname of the database. And we have the password. And we are ready to connect to this database. So let's go to our code editor, create a new file, I'll call it key. Open the new file and paste the content of our private key. Then using the terminal, we are going

Connecting via SSH in SQL Pro1:57

connect to this database. So let's go to our code editor, create a new file, I'll call it key. Open the new file and paste the content of our private key. Then using the terminal, we are going to change the permissions or mode of this file using the chmod command. So chmod 600 key. Now we are ready to connect. Let's open SQL Pro, select an SSH connection. We need to grab the hostname from Weber. So let's do that and put it here. For the username, we will use Weber. And then we grab the password from here. Now for the SSH host details, let's head to networks, choose our network, scroll down. And then we can copy the hostname of our jumpbox and use it as the SSH host. For the user, we will use EC2 user. Finally, for the password, we will choose our private key file instead. Then we click connect. And here we go. We are now connected to our private database through the jumpbox we created.

Scaling Challenges with DB Connections3:06

Finally, for the password, we will choose our private key file instead. Then we click connect. And here we go. We are now connected to our private database through the jumpbox we created. And we can see that Weber has created an initial database for us called Weber. We can connect to this database or rename it or use it as it is. All right, now that we know how to create and connect to databases from our serverless Laravel applications, let's discuss the downside of having a highly scalable web application that connects to a database. We know that lambda functions can scale out very fast to handle an increase in traffic. That means our application will need to establish a great number of connections to the database very fast as the traffic increases. And each connection requires a chunk of memory to be allocated to it, as well as CPU power to establish and terminate it. Also, each Laravel web request, QDrop or artisan command establishes a

Adding a Database Proxy4:00

And each connection requires a chunk of memory to be allocated to it, as well as CPU power to establish and terminate it. Also, each Laravel web request, php artisan command establishes a connection with the database and keeps it alive until the work is done. This database connection may not be needed throughout the entire lifetime of the request, the job or the command handlers. Between creating many connections too fast and keeping the connections alive during the lifetime of the handler, the database can easily get overwhelmed. And to deal with this issue, we may use a database proxy. Let's see how we can do that. We will head over to the Weber dashboard, click on databases and choose our database. From this menu right here, we can select add proxy. Weber will show us some information about database proxies. The important thing to notice is that AWS creates the proxy inside private subnets, meaning that we will need to attach

Private DatabasesDatabase Proxies

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟