Hi All,

I am developing a portal in PHP(YII framework) and MySql DB.
I have 2 queries releated to performance of a portal.

1> How to organize the file/directory structure so that the file/s will be accessed at optimal performance.
for ex : if we take website like Facebook we can see that they are keeping Javascript, CSS and images in different domain(or some websites storing these files in sub domain) What is the use of keeping the scripting files (JS,CSS,Image folders, etc) in another domin. will it help in acheiving greater performance?

2> I want to know about hosting, whether hosting on a dedicated server is better or Cloud hosting is better. (Since i am expecting atleast ten thousand hits a day)

Also any further discussion on managing Portal/ Security of Portal is appriciated.

Thx in Adv.

Dani AI

Generated

Updated, practical notes for (PHP / Yii, MySQL) that build on the points from and —focused on production delivery, hosting tradeoffs, and quick security reminders.

Domain sharding (multiple static subdomains) was a useful HTTP/1.x trick but is generally counterproductive with modern protocols: HTTP/2 and HTTP/3 multiplex multiple streams on one connection, and extra DNS/TLS handshakes from sharding can slow things down. Prefer a single origin for assets and let the transport/edge handle parallelism and prioritization. (developer.mozilla.org)

Treat folders (images/, css/, js/) as source inputs, not the production output. Use a build pipeline (webpack/rollup/etc. or Yii asset bundles) to produce minified, fingerprinted files (e.g. app.4f2c9a.min.js) and serve them from a CDN with long cache lifetimes. Example response header for immutable static files:

Cache-Control: public, max-age=31536000, immutable

Also enable text compression (Brotli where available, fall back to gzip) and let the CDN/offload layer handle TLS and edge caching. (web.dev)

On the Yii + MySQL side: use the framework’s asset manager properly (don’t force-copy assets in production), publish/minify bundles for prod, enable query/schema caching where appropriate, and profile slow queries with EXPLAIN to add the right indexes rather than guessing. These steps reduce CPU and DB load more reliably than raw hardware changes. (yiiframework.com)

For hosting: for an expected ~10k hits/day a small cloud VM (with managed DB or a managed DB service) plus a CDN is often the fastest, cheapest way to start—cloud gives easy scaling and snapshots; choose dedicated only when constant high I/O/latency constraints or specific compliance demands justify the cost and ops overhead. Secure the portal by enforcing TLS/HSTS, using parameterized queries/ORM, validating uploads, keeping dependencies patched, and following the OWASP Top Ten. (digitalocean.com)

Recommended Answers

All 2 Replies

1) A browser will usually not load more than two files simultaneously per domain. If you use more domains, it will try to load more files simultaneously.

2) Cloud hosting has the advantage of moving your site around if something goes really bad. But with only 10.000 hits per day (6 hits per minute), I don't think it really matters.

Its really a case of what makes managing the files easier at the end of the day.
It makes sense to have a folder for images, a folder for javascript, a folder for styles etc. and as a site grows you may find it makes sense to have subfolders within those for further organisation – an images folder can become pretty cluttered very quickly. But generally its does you no harm to start off with a just a few basic folders to organise the different types of files as mentioned above.
When your site gets more complex, you will most likely already understand what is needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.