Demo of platform

I have an application built using php/mariadb

i want to create a demo of the site that has standard data in it. A user can then play around with the data.

I do not want the new data entered by the demo user to exist for another user

what are my opions?

Bush BrigadeGo Kart TesterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
What I do is use code like below where I am using 2 databases.  As your pages are being updated from test to live, this ensures you are using test data for your test site and live database for your live site.  I also but an ugly color background in the same manner on the demo site so you can easily tell you are in the test site.  This allows you to duplicate your site/app and use both live and test data.

if($_SERVER["SERVER_NAME"]==="" ){

    $db_host   = "localhost";
    $db_user  = "liveuser";
    $db_word  = "abc123";
    $db_name = "live_database_name";

} else {

    $db_host  = "localhost";
    $db_user  = "demouser";
    $db_word  = "abc123";
    $db_name = "demo_database_name";

Open in new window

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Two simple ways come to mind...

1) Spin up an LXD container for each client, if your data is big.

If you require individual IPs for a high speed App, use an OVH machine + 254 IPs.

If speed's not an issue, use one public IP + HAProxy to split up site requests.

2) Spin up a new demoX site using a different database name to match each demo site.

This is how WordPress works. You can run 1000s of WordPress sites on one machine, as they all have different databases.

Same table names across all sites, just different database names.
Julian HansenCommented:
Is your question about how to isolate demo data from one demo user to another?

If so - are your demo users logging in with a common ID?

If so then you will need to implement a session based storage mechanism where the data in the DB is linked to a sessionID that has a specific lifespan.

User "logs in" and gets a unique ID for their session.
All data they add / change is linked to that ID
Every 24 hours (or whenever) you run a cron JOB that cleans up old data

Without know more about your application it is difficult to give more specific answers.
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

Bush BrigadeGo Kart TesterAuthor Commented:

each user logs in with their own unique user and pass.

for the demo I was going to use a generic user name and pass and use a separate login form for the demo

i fully intended on using separate databases for the live and demo
 only problem is I don't really want other demo users to see what other demo users are doing.

a virtual machine would be a good idea in this respect as I could just spin it up when. a new user logs in and remove it once the user.times out or.logs off

however, I think I would need to.worry about system resources for that.

Bush BrigadeGo Kart TesterAuthor Commented:
I am also using plesk to manage my server
Julian HansenCommented:
VM - what if you are really successful and you have 100's or 1000;s of users hitting your site and testing out the demo - will the VM approach still be viable?

What about the time for the VM to start up?

I am not discounting the VM idea (I don't have enough experience with the current VM on demand setup) however the above questions are what I would try to answer before going ahead.
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
For the demo, why not create a new database on the fly for each user.   For the database, perhaps use the session id for the database name. when a new demo starts, generate the db, populate data, let them in. Every night delete the prior days databases.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Ditto on what Scott said, which matches one of my suggestions.

I run a similar system, except real sites rather than demo sites.

I have a template set of files + database .sql file.

My case template is WordPress. Any set of files + .sql file will work.

When a new site spins up, the entire template is rsync'ed to new site DocumentRoot, database is loaded, wp-cli run to change site name from template to new real site, use a wildcard cert to cover all host names.

Takes <1 minute to generate a new real site.
Julian HansenCommented:
@Scott - why bother with the creation - if you use the session based solution I suggested earlier it amounts to the same thing without the overhead of generating the DB each time.

Again I would ask if you have multiple users hitting the site simultaneously are you going to create a new db for each one of them - and what are the efficiencies around that - as opposed to a single database where records are partitioned by a session_id - which gives the impression of exclusive access.
Bush BrigadeGo Kart TesterAuthor Commented:
The system is based on user IDs stored within the session

When a new user creates an account there would be no data to view. As they dive in deeper the user would begin to add things such as task, images, posts etc.

BUT, i wouldnt want an empty demo. I would want basic demo information to showcase all the workings of the site.

I could create a table whereupon login, the user is given a unique id but also is associated to a non-unique demo user id in which case all the create/update data would be associated to the unique_id. Therefore, other users wouldnt see the changes but this seems like a lot of work to get something as insignificant as a demo. At which point, i wonder if a demo would be better suited in the form of videos.

Julian HansenCommented:
Not sure if this is what you were saying (I am assuming it was) - to paraphrase.

You setup a demo account with static data - when a user is in demo mode he / she gets a combined data set of the static data and the data associated with their account. All new data they create goes against their own account - but they see the data from both.

That would work.

This is obviously predicated on them having their own id to begin with - which implies your requirement is not to provide demo access without first registering an account - is that correct?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
There is another solution that you may want to consider and it request no code modification and easy to maintain / update.

The company I work with, sell medium to expensive application.
They schedule a live demo using Gotomeeting remotely, this let the client play with the application for a while.
By doing this is sales rep can answer client questions and it is easier for the sales rep to close the deal or offer services/ or other applications.
When the session end the data is reset for the next demo.

For serious client or big organisation they also offer one month testing demo, to play safe, each client have their own installation with their own DB. After that period, they reset the DB, disable the account or activate the account depending if the client decide to use it or not.

To my opinion this take less time to do it like this and you don't need to change the code.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.