Scalability and fault tollerance servers. How do it? - php

In our project we have a front-end part with PHP and Apache, a MySQL database and some Mono servers that do some logic (chat, etc...)
It's all completed but before starting and buy the servers i want know how make them scalable and be fault tollerance. We want buy the servers on So You Start.
How can we proceed? What we must buy (possible cheap)? We thinked about a virtualization but we don't know how move.
Thank you in advance.

Amazon has a lot of very good documentation about how to architect their cloud services. I would suggest you start with a free (for 1 year) Usage Tier for learning AWS and testing your application. The free tier It enables you to setup a Unix and Windows instance as well as RDS (Relational Database Server) and email service. You can later add fail-over servers located in geographically dispersed locations. You can also scale easily by adding (and removing) instances as needed.
Start with this overview.

In AWS you can start small and then use AutoScaling with ELB and cloudfront to really scale up as needed.
http://dailytechscape.com

Related

AWS What specs Instance do I need for an online game server to host 100,000 or more people?

I am currently leaning towards the AWS EC2 server. I'm looking at the console right now in which i can host my apis and database.
My question is which instance type should i use?
Which database should be used? RDS or on same instance?
Game will have more than 100k users.
Apis are for authentications and user file saving and retrieval.
sincere suggestions required.
thanks
Nobody will be able to give you an answer to this question. And if they do, they will be wrong.
The only way to know what resources a system would consume is to build it, then test it using simulated load. This will help identify the bottlenecks in the system (disk? database? memory? network throughput?).
You will then begin the iterative process of finding the worst bottleneck, rearchitecting the app or changing system components, celebrating, then repeating the whole test-measure-fix cycle. Welcome to the exciting world of application performance management!
You can also take advantage of the Cloud by scaling your resources based upon load. When the system is busy (eg in the evening), add more capacity. When things are quiet, remove resources to save money. This is exactly what Fortnite does.
See: How would you keep 125 million gamers playing smoothly online? Epic Games shares its Fortnite story. | Amazon Game Tech Blog
Depending upon what data you wish to store, you could consider using Amazon GameLift:
Amazon GameLift is a fully managed service for deploying, operating, and scaling your session-based multiplayer game servers in the cloud. Amazon GameLift replaces the work required to host your own game servers, including buying and setting up hardware, and managing ongoing activity, security, storage, and performance tracking. The Amazon GameLift auto-scaling capabilities provide additional protection from having to pay for more resources than you need, while helping to ensure that your players can find and join games with minimal waiting.
In reading your question, I suspect that your application has not yet been written yet. So, it's a good time to make general architectural decisions (eg using DynamoDB instead of a relational database since it provides fast and predictable performance with seamless scalability), but don't worry too much about minor details. First, you need to make a product that people want to use. That will be a more difficult challenge than scaling to meet eventual demand.
Concentrate on getting your first 100 users and worry about the other 100,000 later.
The question is very subjective to answer. Reason is You need to identify below things before coming to conclusion:
How much CPU per user per month is required?
How much memory is required per user per month?
How much bandwidth you required per user per month?
Once you have an idea about these value, May be you should take a look at how many concurrent users you want your server to give service, before scaling to launch another server.
So for example your website have 50000 users consistently accessing your application, then you should choose ec2 instance accordingly followed by auto-scaling group and load balancer to serve your traffic.
For database you should always go with RDS (For relational DB).DB on EC2 instance is not recommended.
For EC2 Instance types please check instance-types

Migrating from static hosting to the cloud!

So unfortunately I'm a newbie to the application (web) development world. While I did graduate with a CS degree its theory funness hasn't helped out much. However I am trying to jump in feet first. My php application I build is simply sitting on a cheap hosting provider. In order to launch it I'd like to it to be able to scale well (fun buzz word).
However, as I said I'm totally new to it and I suck at git.
So as I've read I'm looking to host the mySql database and the php files on phpfog, my css and images on amazon S3, and then the email server as Amazon SES?
Is this the right frame of mind, and/or will this handle a flurry of (hoped for) traffic?
Thanks!
That's a lot of scaling in mind for just starting out. Keep it simple. Google Apps Standard gives you 10 accounts to work with, and you can a nice GMail interface as a bonus.
Keep your hosting simple for now, you don't need Amazon S3 for CSS and images yet. Silver pricing seems decent for just starting out at PHPFog. Remember you can always increase capacity later on.
Before you say "flurry of traffic", make sure you have a solid business plan. How will you market your product/service? Who are your competitors? What differentiates your product/service? Pretend like you're pitching this to a VC firm.
If you don't have a solid plan to work with, you're throwing too much money at infrastructure that you won't be using.
If you want to learn about the technical aspects of the infrastructure you're choosing, you probably should begin by learning about how it works. http://media.amazonwebservices.com/AWS_Cloud_Best_Practices.pdf
will give you a nice overview on how scaling works on AWS and the cloud in general.

Hosting Web site on cloud service [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Right now I am planning to build a news publication website that should be automatically scalable when traffic is increasing. I have good experience in developing web applications using ASP.NET and PHP. To move forward on selection of specific technology here are some questions for which I need some clarifications.
My primary intention is to reduce the hosting charges. If we choose LAMP this will cost lower than ASP.NET on Windows. As my intention is to host web application on cloud service, will this make any difference? Means, for dedicated servers we need to pay extra cost for Windows O/S if you compare it with Linux. If we go for cloud servers, will they charge anything for O/S for each instance or will they just charge on computation hours irrespective of Operating System?
Do we have complete control (like dedicated server) on cloud instance to install any other softwares?
Do we need to host web server and and database server on multiple instances when traffic is increasing or will a big size instance can handle huge traffic?
Please help me on taking a decision by clarifying above.
AppHarbor is like Heroku for ASP.NET and has a free plan (like Heroku) that includes a MSSQL database and Git based deployment. You may want to check them out.
Depends on the provider. Windows almost always has an additional cost fue to licensing.
Again, depends on the provider. Amazon EC2 and Rackspace Cloud both give you root on the instance.
Depends where your bottleneck is. If CPU and memory are in acceptable ranges, but the site runs slowly, you'll need more instances to handle the network demand. If network is fine but CPU or memory are high, a bigger instance may suffice, up to a point.
PHPFog
EngineYard
pagodabox
All of the above have free plans to start with.
If you're looking for something like Google AppEngine or Heroku for PHP you might wanna try our service http://cloudcontrol.com
i am using phpfog.com, works great, fast, and cheap
i think what your looking for is a service that Google gives, that i think is amazing, they made a cloud solution to your problem where you don't have to worry about traffic and server issues, they balance the traffic of all the projects they are hosting.
The best think about it is that you can start free, and then if your app is very popular and you need more bandwidth usage, they charge, you can check the destails here:
http://code.google.com/appengine/
they only disadvantage for you is that it is mainly in java and you need to learn there framework, but i have heard of proyects that allow you to creat your site in php
But if you want to buy a server i recomend
http://mediatemple.net/
i have tried there service and the have virtual servers, and you have full control and if you need more servers you can extend your project, since its cloud based.
hope this helps
Depending on which provider you choose, you may pay for hours your instance is live, or you may pay for actual CPU usage. Eg:
With Amazon EC2, you pay for hours your instance is up (Windows does cost a little more, but it's built-in and paid by Amazon, though there is an option to bring your own licences)
With Windows Azure, you pay for hours your instance is up
With Google App Engine, you pay for actual CPU time (and get 6.5 hours/day free)
Again, this depends on the provider, eg.:
With Amazon EC2, you have full control over the instance, so you can install anything you like (presumably the ToS has exceptions, eg. for unlicensed software)
With Google App Engine, you can use third party libraries, but you cannot "install" things. You don't get instances in the same way as a VPS, they deal with taking your code and making it run across their infrastructure.
I presume Windows Azure works similarly to App Engine here, and you don't have an actual OS install that you could install software in.
You guessed it, this depends on the provider, eg.:
With Windows Azure, you would need to add additional instances to handle increases in load.
With Amazon EC2, you also need to add additional instances. They have services like Autoscaling and Elastic Load Balancing to make this easier (Autoscaling boots up/shuts down instances based on load).
With Google App Engine, you don't need to do anything. Google will automatically fire up new instances as required, and you will pay only for the additional resources in the same way.
There are many factors influencing which would work out cheapest (in terms of development costs, managing servers, Windows licensing, etc.), so it's hard to say which would be best. You'd need to look at each one and estimate costs. I'm trying to do a similar thing for my small projects, some of the info here might be useful: http://blog.dantup.com/2010/10/google-app-engine-gae-vs-amazon-elastic-computing-ec2-vs-microsoft-azure
I'm using AppFog for my applications, they support various platforms, such as Java, PHP and Python, once you're using them, updating your application and mapping it to a url is a breeze and very quick. they also support different services such as MySQL and MongoDB.

Super fast server for php script

I have a php script which requires no web hosting or disk space etc.
The script simply retrieves infromation from a server, does some processing on this information
and than passes it on to a client (an iPhone app in this case).
The only thing is that if traffic gets high than there is a high demand for bandwidth and speed.
Does anyone know of a service with high speed and badwidth (apart from web hosting services) that allows you to host (on a static ip) such a php script?
Thanks.
You may want to try some sort of cloud service where you can set up the environment you actually need. Let's say your script need a lot of RAM but only little CPU power (or the other way around) you can have exactly such a system. Amazon EC2 is one of many cloud computing providers out there.
hmm the performance point you can use something like "Facebook HipHop" to convert your php script into "c++" then you have the performance you need.
Cloud solution is perfect. You can even write shell scripts to increase decrease RAM whenever demand goes up.
Like everyone here mentioned, cloud hosting is your best bet. It's slightly more expensive for resources & bandwidth than a dedicated but is superior in performance/latency/scalability. I have a similar application setup for a current project and I am running on the RackSpace cloud with 100K+ active users on a daily basis and I have had no problems (been running for 6 months).
If your code is simple, don't use Php !
You can consider:
Python
GWan server + C
Java
Php is good for big project because its simple, fast to use/test/debug ...

Architecture of a PHP app on Amazon EC2

I recently experienced a flood of traffic on a Facebook app I created (mostly for the sake of education, not with any intention of marketing)
Needless to say, I did not think about scalability when I created the app. I'm now in a position where my meager virtual server hosted by MediaTemple isn't cutting it at all, and it's really coming down to raw I/O of the machine. Since this project has been so educating to me so far, I figured I'd take this as an opportunity to understand the Amazon EC2 platform.
The app itself is created in PHP (using Zend Framework) with a MySQL backend. I use application caching wherever possible with memcached. I've spent the weekend playing around with EC2, spinning up instances, installing the packages I want, and mounting an EBS volume to an instance.
But what's the next logical step that is going to yield good results for scalability? Do I fire up an AMI instance for the MySQL and one for the Apache service? Or do I just replicate the instances out as many times as I need them and then do some sort of load balancing on the front end? Ideally, I'd like to have a centralized database because I do aggregate statistics across all database rows, however, this is not a hard requirement (there are probably some application specific solutions I could come up with to work around this)
I know this is probably not a straight forward answer, so opinions and suggestions are welcome.
So many questions - all of them good though.
In terms of scaling, you've a few options.
The first is to start with a single box. You can scale upwards - with a more powerful box. EC2 have various sized instances. This involves a server migration each time you want a bigger box.
Easier is to add servers. You can start with a single instance for Apache & MySQL. Then when traffic increases, create a separate instance for MySQL and point your application to this new instance. This creates a nice layer between application and database. It sounds like this is a good starting point based on your traffic.
Next you'll probably need more application power (web servers) or more database power (MySQL cluster etc.). You can have your DNS records pointing to a couple of front boxes running some load balancing software (try Pound). These load balancing servers distribute requests to your webservers. EC2 has Elastic Load Balancing which is an alternative to managing this yourself, and is probably easier - I haven't used it personally.
Something else to be aware of - EC2 has no persistent storage. You have to manage persistent data yourself using the Elastic Block Store. This guide is an excellent tutorial on how to do this, with automated backups.
I recommend that you purchase some reserved instances if you decide EC2 is the way forward. You'll save yourself about 50% over 3 years!
Finally, you may be interested in services like RightScale which offer management services at a cost. There are other providers available.
First step is to separate concerns. I'd split off with a separate MySQL server and possibly a dedicated memcached box, depending on how high your load is there. Then I'd monitor memory and CPU usage on each box and see where you can optimize where possible. This can be done with spinning off new Media Temple boxes. I'd also suggest Slicehost for a cheaper, more developer-friendly alternative.
Some more low-budget PHP deployment optimizations:
Using a more efficient web server like nginx to handle static file serving and then reverse proxy app requests to a separate Apache instance
Implement PHP with FastCGI on top of nginx using something like PHP-FPM, getting rid of Apache entirely. This may be a great alternative if your Apache needs don't extend far beyond mod_rewrite and simpler Apache modules.
If you prefer a more high-level, do-it-yourself approach, you may want to check out Scalr (code at Google Code). It's worth watching the video on their web site. It facilities a scalable hosting environment using Amazon EC2. The technology is open source, so you can download it and implement it yourself on your own management server. (Your Media Temple box, perhaps?) Scalr has pre-built AMIs (EC2 appliances) available for some common use cases.
web: Utilizes nginx and its many capabilities: software load balancing, static file serving, etc. You'd probably only have one of these, and it would probably implement some sort of connection to Amazon's EBS, or persistent storage solution, as mentioned by dcaunt.
app: An application server with Apache and PHP. You'd probably have many of these, and they'd get created automatically if more load needed to be handled. This type of server would hold copies of your ZF app.
db: A database server with MySQL. Again, you'd probably have many of these, and more slave instances would get created automatically if more load needed to be handled.
memcached: A dedicated memcached server you can use to have centralized caching, session management, et cetera across all your app instances.
The Scalr option will probably take some more configuration changes, but if you feel your scaling needs accelerating quickly it may be worth the time and effort.

Categories