Web Hosting Forums

Results 1 to 11 of 11

This is a discussion on Different domain names, same database in the Hosting Talk & Chit-chat forum
In a dedicated server (jaguarpc or any other servers) can you setup different domains and connect them to a single database? let say i have ...

  1. #1
    Loyal Client
    Join Date
    Apr 2004
    Posts
    39

    Different domain names, same database

    In a dedicated server (jaguarpc or any other servers) can you setup different domains and connect them to a single database?

    let say i have a database named X

    and i have two domains:

    domain1.com

    and

    domain2.com

    can i connect this two domains to one database? maybe using it as "localhost" is this possible? any feedback would be really appreciated.

  2. #2
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    5,884
    Yes, you can. The databses are completely separate from the domains and user accounts. CPanel uses your account username as a prefix to database names and usernames in order to prevent two users from trying to use the same name, but MySQL itself doesn't care what you use for names. As long as you are using a username that's been granted access to the database you are trying to use MySQL doesn't care where you're coming from. In fact, if you set up access control correctly, you can even call a databse from a completely different server (by changing 'localhost' in your connection settings to an address or IP of the remote MySQL server.

    As an example of what you wnat to do, look at JPC. They run two sites, jaguarpc.com and aletia.com. Each site has its own vB install, but both display the same posts because they are calling the same database.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  3. #3
    Loyal Client
    Join Date
    Apr 2004
    Posts
    39
    thank you for the useful info jason...

    you can even call a databse from a completely different server (by changing 'localhost' in your connection settings to an address or IP of the remote MySQL server.
    wow, i didnt know that! that is cool! i will look for more info regarding this topic...

    again, thanks for the useful tips..

  4. #4
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    5,884
    Originally posted by Polo
    wow, i didnt know that! that is cool! i will look for more info regarding this topic...
    Yes, its true. If you are using a cpanel server then MySQL is by default locked down to only allow connections from localhost, but at the bottom of of the page where you create and delete databases there is a section called "Add Access Hosts" which allows you to specify the names or IP's of other computers that are allowed to access it.

    If you go to http://dev.mysql.com/downloads/ you'll find a download called MySQL Connecter/ODBC wich is a Windows ODBC driver for MySQL. With that you can connect to your database from Windows computers. With a little work you can even link your tables to Microsoft Access databases and make updates to them through Access.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  5. #5
    || $name ne 'R.Stiltskin'
    Join Date
    Jun 2003
    Location
    Tejas
    Posts
    2,414
    Jason - Great tip and nice to know. Now I'll have to figure a way to capitalize on that feature.

  6. #6
    Loyal Client
    Join Date
    Apr 2004
    Posts
    39
    awesome, that was sure more than I wanted to know, but hey, who doesnt like learning? i love it.

  7. #7
    Ron
    Guest
    Jason!

    Be careful about the info you give! I really don't think it's a good idea to give such information out without putting it into a proper frame. While technically correct, you're not mentioning WHY someone might NOT want to do these things!!!

    In regards to remote database access, you passwords will probably be sent in the clear, you're opening your databases to all sorts of security problems, you will have tremendous latency problems outside of the JAG LAN, and even inside the JAG LAN latency will increase by gazillions of percent, though the absolute effect on most uses might be negligible.

    If people started doing remote database activity within the JAG network, everybody else will suffer. Reliability of your application is severely compromised as now you are dependent on multiple machines and all internal netweork components as multiple points of failure. Further, when sockets and/or other communications issues cause a site to go down, JAG tech support might not be able to assist as readily.

    As far as multiple domains on the same server -- go for it!

  8. #8
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    5,884
    Ron, you make some good points.

    Accessing databases from remote computers is a fairly common practice in the business world, but the circumstances are different. The servers that host those servers usually only host the databse and the number of concurrent users is, to some degree, limited. For example, we use an Oracle databse at work to manage our accounting system. Department heads and secretaries have access to this system through software installed on their computers to post payroll, make purchase requisitions, and do other accounting-related functions. Campus wide, there are only a few hundred people who have access to that system and the chances are minimal that all of them will be trying to use it at once.

    In contrast, your JPC server does a lot more than just host a database. It hosts a web server, POP/IMAP/SMTP servers, FTP server, etc., etc. At any given time it could have 500, 1000, or more connections to it as people try to download web pages, access their mail, or manage thier sites.

    Connecting to a database through Access is something that I stumbled upon one day. We have an MS SQL server here at work and I have a database I manage on it. When the DB Admin set it up, he set up a "Microsoft Access Project" (.adp) file on my computer so I could use Access to access the databse. I had never known that could be done and it made me curious to see if I could do the same with MySQL. It is a different method for connecting to MySQL, but it is possible to do something similar.

    Personally I don't really have a use for using Access to get at my MySQL data. Everything I need to do I can either do from MySQLAdmin or through my own scripts. I suppose that if you're familiar with Access (which I am not) you could set it up to do reporting of your MySQL data or something like that, but other than that, there isn't really much of a need for it--at least not that I can see.

    Connecting to another program (other than Access) might have some benefits, like possibly downloading orders from your shopping cart into your accounting software autoimatically (if it supports it). But like Ron said, note that your password is probably sent in the clear, so be careful.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  9. #9
    Ron
    Guest
    In a business environment with a backend database server, the systems are designed to work in that manner. The database is in a secure area not exposed to the net. The applications are designed to reduce latency issues. Stored procedures are used to reduce load on the server and reduce network traffic, and improve performance. Connections to the database are frequently persistent, and there are application services waiting to be called to handle the database requests. Things are cached appropriately. Loads balanced.

    Take phpbb for example. To paint the index page, it makes something like 12 queries to the database. First a connection is opened. Then cursors are opened to read a configuration table, forums, posts, users, categories, user goups, authorization, private messages tables, private messages table, and gawd only knows whatelse. Each one of these is performed synchronously, waiting for the reply before the next operation can begin. All of this is done by building dynamic SQL on the fly, the least efficient method possible. Also, might I add, the decisions about what database is being run and how to code the sql is also being made in the presentation layer. How awful.

    Anyway, back on point, all of those queries are passed one at a time to the database, which is the queries for each result row in a cursor. Now I don't know much about MySQL, so they may or may not have implemented client-side cursors. If they don't, then for each row of the result, a fetch and return would be made across the network. So the number of network requests goes up as the number of categories and topics goes up.

    Now, depending on how the network is set up and depending on how TCP/IP is implemented on each server, each one of those communications will be measured, and if the transport packet is less than a certain percentage full, say 60% (and it likely will be for these small requests and responses) The packet waits for a little bit to see if there's another batch of info to be deleivered to the same IP. If no other request comes along, the packet will be sent.

    That's called the Nagle Algorithm, and it's designed to reduce the number of packets and overhead on the network. The tradeoff is in packet delivery latency. The Nagle Algorithm can be turned off on the server if the network guys will allow it, and can be turned off on a socket-by-socket case by the application when it opens the socket. (ip_proto TCP_NODELAY, if I recall).

    A well designed system would send a request with login information to an application on the backend, which would reply with an object containing all of the information required to produce an index page. One shot, of one to N packets filled with data.

    Sure, you can throw together a system and it'll work -PHP proves it- but when you run ito trouble, the performance is slow, reliability or security is poor, can't handle more users, whatever, you'll have wished you did it right in the first place. Heck, , php starts to croak on a dedicated server with just a few hundred users on it, doing nothing but essentially reading text! They have to go out and build static pages of the text because the database can't handle all the queries! (Oh yeah, and the presentation "layer" LOL, don't get me started on THAT! What a joke.)

    Just because it CAN be done, doesn't mean it SHOULD be done.

    And accessing Oracle through MSAccess was one of the coolest nerdy things when I did it too! (Don't tell the DBAs)

    I'm sorry, was all this out loud?

  10. #10
    Loyal Client
    Join Date
    Sep 2002
    Posts
    640
    Ron,
    with all the respect, I think the points you raised are irrelevant

    Not all applications should be designed and implemented with load balancing, reliability and scalability in mind. In the real word, there is a trade-off between technically good decisions leading to time consuming and costly development and 'bad' design which can be implemented faster and cheaper.

    Take phpbb for example: it does its job and, as a user, I wouldn't care about how much queires it takes as long as it suits my needs. Making it 'better' would benefit a tiny fraction of phpbb's users and would force all others to 'pay' for it.

    The technical insight you offer also hardly applies to the environment which is of interest to your readers.
    For one, MySQL is nothing like Oracle.
    For two, even for small requests and responses, SQL queries are relatively big. For three, the latency is hardly noticable even if it would occur with the small queries.

    "Just because it CAN be done, doesn't mean it SHOULD be done" can work both ways. If something can be done technically better, it doesn't mean it should be done that way

  11. #11
    Ron
    Guest
    I didn't say that polo should go with a more advanced solution; in fact I was arguing against it. Sorry I didn't make that abundantly clear.

    What I said is if someone is going to distribute an application across servers, there are a multitude of issues that need be considered, and then I proceeded to give examples and explanations of why that is.

    I used phpbb as an example as well, though I did get a little deeper into its deficiencies than needed. The point is people have made a technology choice in using phpbb and mysql, and now they are stuck bigtime. Just ask the people who have chosen phpbb and now are required to move to dedicated servers to handle the load of a few concurrent users on a glorified text update and display system. Rhetorically ask them if it was a good idea to choose phpbb and mysql.

    The clear choice for someone of Polo's technical prowess and resource needs (for two shared accounts) here is to get their two or more sites co-located on the same server, and like I said, go for it. Even if he needed more, a semi-ded or dedicated server, the apps should be colocated on the same box.

    Not until he required the horsepower of multiple boxes should distributing an application be considered.

    Initial good choices in technology frequently don't have to be more expensive, and usually cost less in the long term.

    IMNSHO

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •