i am new in this material so i have 2 questions to ask in this 1 post
first of all, i am a PHP developer who wants to host my application into my own PC
(my application is something like social media assuming will have many users)
(i dont want to use any Public WebHosting / VPS , considering cost and security of my data)
and i decided to make my own webserver for my Start-Up Company
but the very problem here is the cost to buy a Server is too expensive if we compare to Desktop PC
and my question no 1 is
For a WebServer based on PHP (Apache) which used Sql Server as a Database , can i just use Desktop PC instead of using Server?
(considering it will online 24hours / day and processing big amount of request. Assuming i have many users online at the same time)
If let's say i bought 1000$ Desktop PC which i maximize the money at Processor, Memory and Storage
will it worth more than if i bought 1000$ Server which i maximize the money at Processor, Memory and Storage also
question no 2 is
if i must use Server instead of Desktop PC as my Webserver, i will use Windows Server as my OS,
but if i can use a desktop PC , can i use Windows 7 Professional instead of using Windows Server?
because some website told me that Windows 7 Professional is not as powerful as Windows Server For a Normal Server (but i dont know about WebServer)
and i dont really know what's the disadvantage if i use Windows 7 Professional instead of using Windows Server as OS for this PHP application
I'll address your first question :
The main issue with a PC as a server is availablity and security.
Servers are secured and configured in a way that will prevent most issues that you would normally wouldn't think about, like disabling eval, disabling exec, disabling file_get_contents on default, and many other things, hosting companies provide support and assistance on a wide variety of topics.
(Automatic backups of sql, machine users and files also).
the 2nd issue is that if your house loses power, your website is down. if your hd crashes, it takes hours and hours to replace, reinstall, reconfigure and re-deploy your website.
Don't expect your new app to be the next LinkedIN or Twitter or facebook when it comes to traffic and usage, Just start with a small hosting company for the cost of a few $ a year(you can get really cheap hosting, but you get what you pay for) and upgrade accordingly.
With 1000$ you can buy really good hosting with superb stats for quite a long time.
My suggestion is start with a web hosting, and grow slowly, most hosting companies will allow you to upgrade.
You can use your local machine as a developer environment, but the actual deployment should be done on a server.
The first question is the internet bandwith. At data centers the bandwith is usually much better than at home PC.
The second question - the 'white' IP address, that can be accessible from everywhere. Not all internet service providers provide this service.
So, i think you can give a try, if you have good ISP provider.
Also i think you can use linux instead of windows, if your project is a PHP based site.
What do you use as sql database? MySQL, PostGreSQL, MariaDB or Microsoft SQL server?
I think Windows is only needed, if you want to use Microsoft SQL. In all other cases Linux can be easier to use and cheaper alternative.
Related
Overview
I have a Laravel 9 application which is hosted with Digital Ocean. I use Laravel Forge to handle provisioning of the servers, management, etc. I've created two separate servers for my production environment. One to host my Laravel application code and another for the database which runs MySQL 8. These two servers are networked together and communicate over their VPC assigned private IP addresses.
Problem
I initially provisioned one server to host my application. This single server hosted both the Laravel application code and database. I have an endpoint that I hit to measure the response time for my application.
With one server that hosts the codebase and database the average response time was: ~70ms
When I hit the same endpoint again but with my two dedicated servers the average response time was: ~135ms
Other endpoints in my application also have a significant increase in response time when the database lives on a dedicated server vs a single server that houses everything.
Things I have done
All database queries have been optimized. (n+1, etc.)
Both networked servers are in the same region.
Both networked server's resources (CPU, RAM) are low and are not capping out.'
I've turned on Laravel's database config "sticky" option with no noticeable improvements.
I've enabled PHP OPcache for PHP 8.1.
Questions
How can I achieve a faster response time when my database is on a separate server than my codebase?
Am I sacrificing performance for scalability with dedicated servers?
TLDR
I'm experiencing slower response times in my Laravel application when the codebase and database run on separate dedicated servers vs hosting everything on one server.
Are your servers in the same data center and on the same VLAN?
Are you sure that you are connecting with your private VLAN IP address?
Some latency is expected if you need to connect to a database on another server. Have you tried to ping between the servers to see what the latency is?
Do you really need to have the web server and the database on separate servers? If so, I would probably try Digital Oceans managed database. I have used that for several projects and it works great.
Q: How can I achieve a faster response time when my database is on a separate server than my codebase?
A: If hosted in the same data center, the connection latency should be 30ms or less. Tested between AWS RDS and EC2 instances. Your mileage could vary depending on host.
Q: Am I sacrificing performance for scalability with dedicated servers?
A: It's standard practice to host databases separately to your application. It would be unrealistic to do otherwise for bigger projects. You can soften the impact by selectively caching data that doesn't change regularly on the main server. Unfortunately, PHP is not particularly good at this kind of fine tuning so you might be out of luck.
I can tell you that I currently run a central MySQL RDS instance that many ubuntu EC2 instances communicate with. While the queries take around 30ms, smart use of caching gives the majority of my web requests a 30ms response time in their own right. I do have the advantage of using NodeJS which is always doing things in the background without needing a request before performing work.
You may unfortunately find that you're running into one of the limitations of PHP.
I'm doing a group project and we're creating an online game. We're about half way done and now it's time to implement a database to store our records/data and make the website go live on the internet.
I'm just confused on how PSQL works exactly. My understanding is that PSQL needs to be running on some server in order to access it. For previous assignments, I downloaded Postgres for my Mac and ran it on localhost. The PHP code was something along the lines of:
$dbconn = pg_connect("host=localhost port=5432 dbname=mydbname");
So, if we intend to use PSQL, where would the server be? Do one of us have to host the server? Can we use some sort of free online server? How do we connect to that server with PHP?
In summary, I have two main questions:
How do we make our code go live on the internet for free? (It's just a temporary website and will only be up for a few weeks at most)
How can we all access a shared PSQL database?
Sorry for the noob questions, I just got started with web development and am still learning.
So, if we intend to use PSQL, where would the server be? Do one of us have to host the server? Can we use some sort of free online server? How do we connect to that server with PHP?
PostGreSQL is going to have to run on some machine visible to anyone who needs to access it. If only your web server (i.e., the machine running PHP and your website) needs to talk to the PGSQL, then PGSQL can be installed on your web server. This is a very common configuration.
The server might also run on the LAN where your web server is running or it might be running on an entirely different network on a different continent. The most important thing is that any machine which must connect directly to the database can actually connect to it. If you're building a website, this means you have a web server. Your web server will need to connect to the PGSQL server. The second most important thing is that your web server and the PGSQL server should share a very fast connection for the sake of performance and efficiency.
It's probably most common for your web server to also host the database. On an ubuntu machine, installing a PostGreSQL server is as easy as running a few commands. A quick search yields many examples like this one.
How do we make our code go live on the internet for free? (It's just a temporary website and will only be up for a few weeks at most)
I don't know anyone who is in the habit of offering free web hosting or DBMS services. You could ask a friend. Or put an ad on craigslist or something. Or if you are tech-savvy (it doesn't sound like you are) then you could configure a high-end router at your home to use Dynamic DNS to point some domain at a machine running at your house.
How can we all access a shared PSQL database?
I have no experience with Heroku, but you might sniff around there. PostGreSQL's website also maintains a list of hosting companies. Amazon offers RDS instances running PGSQL. Digital Ocean has a variety of tutorials and how-tos on dealing with PostGres. You could probably fire up a 'droplet' server for super cheap and install it yourself without too much effort.
Amazon offer a free tier database solution for Postgres. Something like 300 hours (don't quote me on it) for a low level set up.
They have tutorials on doing this here:
https://aws.amazon.com/rds/?nc2=h_m1
Once set up you get the end point and your connection string becomes something like
db_connect ("host=[URLENDPOING] user=postgres dbname=postres")
First, I am a complete novice when it comes to programming, so pardon my ignorant questions.
I hired two programmers to work on my project. They say they need a remote test server for testing things, before making it live, so that the changes are not live until all are okay.
My questions:
What are Remote Test Servers?
Why are they necessary?
Can they be set up with normal reseller or shared hosting?
How can you prevent the world from seeing what's on it?
Do you need a domain name for this?
How do I go about setting up a remote test server?
Any other comprehensive document to read up on this?
Thanks.
About Test Servers
A test server, in the case of websites, is used for changing around a website ( a copy ) without it being displayed to the public. This is done because, when a developer changes a webpage, the page will often seize to function or contain bugs due to incomplete changes of the source code. By putting these pages on a remote test server, the developers can use copies of the website - that are placed on this server - to make changes without affecting the pages that are being sent to the clients. You can actually configure this kind of server locally or remotely, depending on how you weigh the pros and cons.
Remote Test Server
You may set up a remote test server on sites like GoDaddy or DynDns. These services usually package a domain name with their server space. The benefit of this is that most of the 'set up' is already done for you. Also, as Silvertiger has pointed out, the service fees of this are usually quite low. This might be recommended because the massive amount of software your programmers may need is readily available on these servers. The only downside is that the only way to prevent the public from viewing this ( that I know of ) is to make it password protected. However, you may need public access anyway if your developers plan on working outside of your work environment.
Local Test Server
Alternatively, you may set up one of your own computer as a test server. The benefit of this is that the only fees you will have to pay are the costs of the computer ( it can be a low-end computer ). Since this computer would be connected to the network you wouldn't need a domain name, instead you will use an IP address assigned to the machine. It won't be hosted on the internet, so it's much easier to prevent other people from seeing it. The only downside is that your programmers must be within your network to work and setting this server up may be rather involved ( depending on the needs of your programmers ).
You will mainly have to download and configure all the appropriate software ( ie Apache, mySQL, PHP ) to get it working. This is typically done on a server OS ( ie Ubuntu Server ), but can be done on most operating systems. This process can also be made less painful by installing server software packages ( ie WAMP, LAMP, MAMP ), which include the basic software components your developers will need. I would recommend using Ubuntu. You may use Ubuntu Desktop if you'd like to keep a graphical interface during set up. Or, you may use Ubuntu Server - which saves a lot of memory by using a terminal-based user interface ( can make it more difficult to use ).
You may additionally consider adding a service called FTP to a local server. This is a service that allows you to remotely read and write to files on the server, and may be desired by your web developers for some of their editing programs ( Dreamweaver, for instance, can access files with FTP ).
As a side note, most developers should be familiar with setting up basic server software. In fact, it is usually part of the curriculum in webdesign. So, you may allow them to configure this software if you provide the computer for them. If you otherwise would like to configure it yourself, you may find some of the links following to be helpful.
Informational Links
General Web Servers
Wikipedia - general information on web servers
HowStuffWorks - information on how web servers work
Remote Servers
Godaddy - A common web hosting company from which you may use their service.
DynDns - ( as the aforementioned )
Local Servers
Ubuntu Server : A popular OS for servers
Apache : A popular HTTP server ( aka Web Server )
PHP : A commonly used language by web developers
LAMP : A package of basic server software for Linux ( Linux Apache mySQL PHP )
WAMP : A package of basic server software for Windows ( Windows Apache mySQL PHP )
MAMP : A package of basic server software for Mac ( Mac .. .. PHP )
Setting up LAMP : [Steps 1-5] A wonderful article on setting up a web server on Ubuntu.
A remote test server is a working php server that you can execute code on. It can be any server you have access to meaning that any reseller of hosting can provide you with a server but effectually it is just a web server you have access to. I presume you have a software that is asking for a remote test server like Dreamweaver or some other IDE.
I use my godaddy $8 a month hosting account account for testing..
OK, here's my problem, I have 1 main server with a measly 128M of RAM. I also have a few other servers but they cannot support certain things making them not usable for a web server (not ideal for development (technical reason)). But the thing is that these servers have 4GB of ram. I want to put them to some good use and allow them to be used as memcached buckets?
Is this possible?
Of course you will think I am crazy for not using the 4GB server but I am not able to as the service provider disallows certain ports (25 is the one causing me issues as my web application requires mail).
I am using PHP. Please tell me, if this can work then what I need to install if I am not using the memcached server on my web server.
Also what ports will I have to forward?
Thanks in advance.
If your application needs memory, run it on those servers anyway! Use your server that has full access to the internet as nothing more than a gateway to those servers.
You can do this a variety of ways, from simple routing, NAT, proxying, or even just mapping some ports over.
and I've read a bunch of related posts here on SO and have gotten the following ideas here:
First, my website is shared-hosted at 1and1.com. And my objective is to call exec() in my PHP code to run ffmpeg to convert short videos (30 seconds) from format A to format B.
1) Now, because of my shared hosting situation (the 1and1 web server my website runs on is shared with other 1and1 customers) -- 1and1's administrator probably has their server in 'safe' mode, so that my desire to exec() in PHP to do the ffmpeg conversion of a video -- will fail.
(Supposedly there is a 'safe mode' shared directory but that's a hoop to jump through with 1and1).
2) And even if 1and1 does not mind if, from my PHP code, I call 'exec( ffmpeg -i yada yada)' for converting between video formats -- I've heard it's unseemly to do that. I'm led to believe I need a dedicated server and not a shared server. Which sounds weird because (a) the web site will never scale to massive # of users, and (b) when I run ffmpeg on my 2 1/2 year-old laptop, Windows Vista, running Xampp as my localhost development web server, the conversion happens like right now. Very fast.
Are the above restrictions correct ('safe mode' on shared web hosting, running ffmpeg is a no-no without a dedicated box)?
I'd like to think that 1and1 would not even notice if my web site did a few (say, under 20) short-video conversions per day.
Also if anyone can recommend the proper web hosting company for my situation I would be in your debt. Thanks.
I believe safe mode would allow you to use exec because 1and1 would have you chrooted so any program you run would not be able to access other users. But, you might want to check the AUP to see if the prevent those kind of processes (that consume a lot of resources).
For the best performance you should use a VPS server in which you can control your php environment. ffmpeg has potential to be very resource intensive, so for best performance a VPS/dedicated would be best. Also, using ffmpeg on shared hosting would impact performance on other sites as well.
Any VPS would do, but because you asked for a recommendation, I would recommend BlueMileCloud.
PS: You should never call a process directly from exec. You should add it to a queue, so the script does not wait for the process to finish and cause the site to hang.