11 Things to Consider Before Deploying Your Rails Application

from: [url]http://vinsol.com/blog[/url]

At VinSol, we have been developing and deploying Rails applications for more than four years. During this period, we have identified some best practices that we prefer to follow while deploying rails application to production server.

Below is the checklist of these practices:


1. Ensure that NS records and MX records are changed if they need to be changed

Changing nameservers will point the domain to the hosting server, and changing MX records will redirect incoming mails to the mail server. As a very first step, we should make sure that name servers of the domain are set to be the correct one. Changing MX record is a must if our application is parsing incoming mails or we wants to use other mail services for e-mail exchange, for example Gmail.



2. Ensure some backup mechanism in place for both data as well as user uploaded content like images/documents etc.

Since production data is very critical, we must setup backup mechanism. It could be some type of scheduled task that takes periodic backup of all critical data, Or it could be some type of backup service provided by hosting company. When we talk about critical production data, it includes production DB, content generated by application users like images, documents, etc.



3. Ensure database indexes

We might have done development without having proper database indexes, but we should avoid going to production without them. Adding indexes might slow down insert queries a bit but it increases the performance of read queries. It applies when application in production has percentage of read operations much more than write operations.



4. Enable your slow query log

This is specific to MySQL. Enabling slow query log allows MySQL to log slow running queries to a file. And this log can be used to find queries that take a long time to execute and are therefore candidates for optimization.



5. Ensure exception capturing is in place

We might want to be notified when something bad happens to our application. There are several hosted services available who receive and track exceptions, for example Hoptoadapp.com, GetExceptional.com etc… Either we can choose one from these hosted services or we can use “exception notifier” plugin.



6. Ensure adding entries for cron/scheduled jobs

Most of the applications have some functionality/jobs that need to be run periodically, for example generating invoices, sending newsletters etc. In most cases these jobs are done by a rake task. We should make sure that we have added such jobs to cron or similar program.



7. Monitoring important processes

To ensure that our site is up 24×7 we need to ensure that all processes that our application needs are up. There can be many processes like MySQL, Mongrel, Apache etc.. These processes are very important as our application directly depends on them. For example if MySQL process get killed accidentally, our application would not be able to connect to MySQL and will start throwing exceptions.

We can choose any of the available monitoring tools like God, Monit, 24×7 etc…



8. Ensure confidential data filtering

We would never like to leak/share confidential information of our application users. We should make sure that none of the user’s confidential data like SSN, Credit card info, password are being written to log files. We might not have paid much attention on this while developing the application.



9. Rotate log files

Once our site is up and running, every single request write some text in log file. And hence size of the log file keeps on increasing. Larger log files can put us in trouble if we get it beyond certain size. Its difficult to manage these log files, as larger files need more memory to open and need more time to download. In one of the rescue project we did , the log file size was 3GB.

We would recommend having logrotate setup for the application.



10. Setup Asset Host

Setting up asset hosts can reduce loading time by 50% or more. We must setup asset hosts for our application. Once asset hosts are all set, our static files will be delivered via asset hosts for example asset1.hostname.com, asset2.hostname.com



11. Clearing up stale sessions

We should make sure we should not left any stale session on the server. If our application is using DB or file system as session store, we must add a schedule task to delete stale sessions.

These are some of the points we have identified from our past experience and we might be missing some. Feel free to always add them as comments, and I’ll keep this post updated.
### 回答1: ctly to a server means uploading the application files and configuring the server to run the application. 直接部署Web应用程序到服务器意味着上传应用程序文件并配置服务器以运行应用程序。 ### 回答2: Web应用的部署是为使其在服务器上运行而将应用程序文件和其他资源文件放置在适当位置的过程。部署通常包括以下步骤: 1.选择合适的服务器:根据您的需求选择最适合的服务器,例如:云服务器、共享服务器等。 2.安装必要的Web服务器:部署Web应用程序的第一步是确保您在服务器上安装了Web服务器。Web服务器承担着从客户端(浏览器)请求和返回响应的任务。例如:Apache、IIS 、nginx等Web服务器 3.获取Web应用程序文件:可以从本地系统或远程服务器获取Web应用程序资源文件,确保它们都在同一个目录下。 4.设置Web应用程序:为了使Web应用程序正确地运行,您需要编辑Web应用程序的配置文件。这可能包括更新数据库连接信息,设置虚拟主机等。 5.创建数据库:如果Web应用程序需要与数据库交互,那么您需要在服务器上创建相应的数据库并设置相应的授权。 6.部署应用程序:最后将Web应用程序资源文件部署到服务器上的相应目录下,并启动Web服务器,在浏览器中使用URL路径来访问Web应用程序即可。 最后,您需要测试应用程序以确保它在服务器上正常工作。如果测试成功,您可以通过设置DNS等配置将Web应用程序运行在公网上。部署Web应用程序要求小心谨慎,因为任何错误都可能导致应用程序的故障。因此,建议在部署之前使用沙箱进行测试来确保安全性和可靠性。 ### 回答3: Web应用程序是一种常见的应用程序类型,用户可以通过互联网访问该应用程序。部署Web应用程序需要许多步骤,以下是一些关键步骤: 首先,需要选择一个可靠的Web服务器。常见的Web服务器包括Apache、IIS和Nginx等。选择服务器应该基于应用程序的具体需求和限制,例如运行平台、安全性和性能等方面。 接下来,需要准备服务器环境。这通常包括安装操作系统、网络协议和所选Web服务器,并确保服务器安全性以及常见的安全更新已安装。 然后,需要将Web应用程序代码上传到服务器。这通常通过FTP或SSH等传输协议进行。如果应用程序使用数据库,还需要安装和配置数据库服务器。 接下来,需要配置Web服务器以正确地显示应用程序。这包括配置服务器以显示正确的Web页面、启用应用程序所需的设置和插件,并处理程序的请求和响应。 最后,需要对应用程序进行测试。这可以帮助发现任何错误或漏洞,并确保应用程序与所选的服务器和配置兼容。测试可能包括单元测试、端到端测试和负载测试。 总之,部署Web应用程序需要许多步骤和技能。但是,通过按照这些步骤进行,可以确保应用程序在Web上成功部署并安全运行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值